Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upHow would you expect this to be formatted? #105
Comments
|
I'd probably do this by hand, but my formatting can be a bit idiosyncratic. def fetch(content, prefix):
return {
'parts':
pipe(
parse('$..layers').find(content),
mapcat(lambda m: m.value),
filter(lambda v: v['exportOptions']['exportFormats']),
filter(lambda v: re.match(prefix, v['name'])),
map(lambda v: glom(v, {
'key': 'name',
'layout': (
'frame',
{
'left': ('x', round),
'top': ('y', round),
'width': ('width', round),
'height': ('height', round)
}
)
})),
sorted(key=lambda p: p['key']),
list
)
}(I can try and write out the general rules I followed here, if this isn't too hard on the eyes.) |
|
Looks much better! is this anything yapf/pep8/prettier could ever do? |
|
FWIW, unrelated to this thread, I saw this project on HN this morning https://github.com/ambv/black seems to be exactly what I was looking for (an opinionated formatter), and also incidentally it formats code almost exactly like you did. hurray! :) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

this is hand-tuned, yapf/pep8 don't really care about any of that (they pass-through, it seems):
with prettier