-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jorge Bastida
committed
Dec 8, 2013
1 parent
cc2e8a6
commit 3f08225
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import json | ||
import codecs | ||
|
||
from base import BaseTextFormat | ||
|
||
|
||
class JSONFormat(BaseTextFormat): | ||
|
||
extension = 'json' | ||
|
||
@classmethod | ||
def populate_argument_parser(cls, parser): | ||
group = parser.add_argument_group("JSON format options") | ||
|
||
group.add_argument("--json", | ||
dest="json_dir", | ||
nargs='?', | ||
const=True, | ||
default=os.environ.get('GLUE_JSON', False), | ||
metavar='DIR', | ||
help="Generate JSON files and optionally where") | ||
|
||
def needs_rebuild(self): | ||
if os.path.exists(self.output_path()): | ||
try: | ||
with codecs.open('output/simple.css', 'r', 'utf-8-sig') as f: | ||
data = json.loads(f.read()) | ||
assert data['hash'] == self.sprite.hash | ||
return False | ||
except Exception: | ||
pass | ||
return True | ||
|
||
def render(self, *args, **kwargs): | ||
return json.dumps(self.get_context()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters