Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ are regenerated by `scripts/regenerate_examples.py`.
| Input | Original | `pymini` | `pyminifier` | `python-minifier` (`pyminify`) |
| --- | ---: | ---: | ---: | ---: |
| `tests/examples/pyminifier.py` | `1,355` bytes | `511` bytes, `62.3%` | `676` bytes, `50.1%` | `1,020` bytes, `24.7%` |
| `tests/examples/pyminify.py` | `1,990` bytes | `1,129` bytes, `43.3%` | `1,605` bytes, `19.3%` | `983` bytes, `50.6%` |
| `TexSoup/` raw Python source (`*.py`) | `98,181` bytes | `31,216` bytes, `68.2%` | `—` | `—` |
| `TexSoup/` compressed source (`.tar.gz`) | `70,532` bytes | `45,065` bytes, `36.1%` | `—` | `—` |
| `tests/examples/pyminify.py` | `1,990` bytes | `981` bytes, `50.7%` | `1,605` bytes, `19.3%` | `983` bytes, `50.6%` |
| `TexSoup/` raw Python source (`*.py`) | `98,181` bytes | `33,107` bytes, `66.3%` | `—` | `—` |
| `TexSoup/` compressed source (`.tar.gz`) | `70,532` bytes | `11,850` bytes, `83.2%` | `—` | `—` |

## TexSoup Validation

`pymini` has been validated against the upstream `TexSoup` test suite in package mode.
Current validation: raw source code `68.2%` smaller, compressed source code
(`.tar.gz`) `36.1%` smaller.
<!-- Raw bytes: 98,181 -> 31,216. Compressed bytes: 70,532 -> 45,065. -->
Current validation: upstream pytest passes (`78` tests), raw source code `66.3%`
smaller, compressed source code (`.tar.gz`) `83.2%` smaller.
<!-- Raw bytes: 98,181 -> 33,107. Compressed bytes: 70,532 -> 11,850. -->

To reproduce that flow locally:

Expand Down
35 changes: 18 additions & 17 deletions examples/pyminify.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
def a(event,context):
f='RequestType';g='PhysicalResourceId';h='None';i='Status';j='SUCCESS';k='Tags';m='OldResourceProperties';l.info(event)
f='RequestType';g='PhysicalResourceId';h='None';i='Status';j='SUCCESS';k='Tags';m='OldResourceProperties';l.info(event);n,o,p,q,r,s,t,u,v=(event,create_cert,add_tags,validate,wait_for_issuance,context,send,reinvoke,acm)
try:
b=hashlib.new('md5',(event['RequestId']+event['StackId']).encode()).hexdigest();c=event['ResourceProperties']
if event[f]=='Create':
event[g]=h;event[g]=create_cert(c,b);add_tags(event[g],c);validate(event[g],c)
if wait_for_issuance(event[g],context):event[i]=j;return send(event)
else:return reinvoke(event,context)
elif event[f]=='Delete':
if event[g]!=h:acm.delete_certificate(CertificateArn=event[g])
event[i]=j;return send(event)
elif event[f]=='Update':
if replace_cert(event):
event[g]=create_cert(c,b);add_tags(event[g],c);validate(event[g],c)
if not wait_for_issuance(event[g],context):return reinvoke(event,context)
b=hashlib.new('md5',(n['RequestId']+n['StackId']).encode()).hexdigest();c=n['ResourceProperties']
if n[f]=='Create':
n[g]=h;n[g]=o(c,b);p(n[g],c);q(n[g],c)
if r(n[g],s):n[i]=j;return t(n)
else:return u(n,s)
elif n[f]=='Delete':
if n[g]!=h:v.delete_certificate(CertificateArn=n[g])
n[i]=j;return t(n)
elif n[f]=='Update':
if replace_cert(n):
n[g]=o(c,b);p(n[g],c);q(n[g],c)
if not r(n[g],s):return u(n,s)
else:
if k in event[m]:acm.remove_tags_from_certificate(CertificateArn=event[g],Tags=event[m][k])
add_tags(event[g],c)
event[i]=j;return send(event)
if k in n[m]:v.remove_tags_from_certificate(CertificateArn=n[g],Tags=n[m][k])
p(n[g],c)
n[i]=j;return t(n)
else:raise RuntimeError('Unknown RequestType')
except Exception as d:l.exception('');event[i]='FAILED';event['Reason']=str(d);return send(event)
except Exception as d:l.exception('');n[i]='FAILED';n['Reason']=str(d);return t(n)
del (n,o,p,q,r,s,t,u,v)
handler=a
Loading
Loading