Comments (4)
This can be worked around by removing those *tab.py
files under the slimit directory (along with the related .pyc
there or inside the __pycache__
directory); you will likely need to be the root user (or sudo
) to remove them and regenerate them (again as root) using the current version of ply
that was also installed (by running python -c 'import slimit;slimit.minify("")'
, and as root for a system level installation).
Really though, this package doesn't look maintained anymore so I ended up forking this, took the good bits as a base for my own.
from slimit.
I get the same verbose dreck spewed out to stderr. This exceedingly ugly one-liner anywhere after import slimit
, but before calling minify()
silences the logging:
slimit.lexer.ply.lex.PlyLogger = \
slimit.parser.ply.yacc.PlyLogger = \
type('_NullLogger', (slimit.lexer.ply.lex.NullLogger,),
dict(__init__=lambda s, *_, **__: (None, s.super().__init__())[0]))
This works for me in Python 3.6 with slimit 0.8.1
and ply 3.11
-- maybe others, but YMMV.
All this does is monkey-patches the PlyLogger
class with the NullLogger
class the ply
package defines itself, adapting for the differences in initializer signatures between the two classes (shame, shame). If ply
has a configuration setting or optional initializer parameter somewhere that effectively does this -- and it should -- I couldn't find it. (Hint, hint, ply
maintainers.) Maybe in lieu of that, slimit
should do this internally instead of putting the onus on the user?
from slimit.
@rod-app The problem actually goes deeper than that - if those messages are generated every time minify
is called, it means that the ply tab modules are being regenerated (which takes as long as a second), and if there are a number of JavaScript files being processed that extra delay and thus performance hit to the program will accumulate rather quickly. Removing the message simply hides the problem but not actually fixing it - the only way to fix it is to manually remove the problematic tab files and regenerate them correct as I had suggested.
The fork that I made (calmjs.parse) does not track the tab files for the source repository, but they are package/generated for every supported (and released) ply versions, such that they are not needlessly being regenerated for the end-users, and in the case a newer version of ply is out there is a specific command (python -m calmjs.parse.parsers.optimize
) with the reasoning behind it explained in the README for the package.
Also please note that slimit has not received a new release for nearly 6 years now, so I made that fork as an attempt to rectify the situation (the slimit minify
equivalent is available via from calmjs.parse import es5
and then call es5.minify_print
).
from slimit.
from slimit.
Related Issues (20)
- Parse function breaks when there’s a line ending in a string HOT 5
- Syntatically wrong callback function validation check succeeds even though it would fail in a browser. HOT 2
- SyntaxError: Unexpected token (CLASS, 'class') HOT 1
- Unexpected token (ID, 'params') HOT 1
- Unexpected token (DELETE, 'delete') HOT 1
- Having promise catch statement breaks the minification HOT 1
- Release? HOT 4
- Minify fails on jquery file HOT 1
- Bug: Error when parsing "`" HOT 2
- how can i get the line number of the node in ast tree? HOT 2
- parser option
- Lose "()" after parse and cause Syntax error in js HOT 3
- Proposing a PR to fix a few small typos
- Release please: No longer installable on Python 3 due to setuptools dropping build_py_2to3 HOT 1
- keywords incorrectly disallowed as object property names HOT 1
- update pypi to reflect python 3 support
- Is there any plans for supporting ES6. HOT 1
- Switch default statement position not preserved (it is not always the last statement)
- Unexpected Token error -- script or slimit issue? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slimit.