reading and writing of entries with the grammar, mostly spaces and newlines changed
This commit is contained in:
@ -3,6 +3,11 @@ ftp://ftp.tuxpaint.org/unix/x/
|
||||
http://antongerdelan.net/blog/ (other projects besides TestDrive)
|
||||
http://cdetect.sourceforge.net/
|
||||
http://circularstudios.com/
|
||||
https://github.com/SadConsole/SadConsole
|
||||
https://github.com/tlgkccampbell/ultraviolet
|
||||
https://github.com/amerkoleci/Vortice.Windows
|
||||
https://github.com/horde3d/Horde3D
|
||||
https://github.com/cxong/cdogs-sdl
|
||||
http://cyxdown.free.fr/bs/
|
||||
http://cyxdown.free.fr/f2b/
|
||||
https://github.com/nfprojects/nfengine
|
||||
|
@ -1,4 +1,4 @@
|
||||
start: title description property+ note? building
|
||||
start: title _EL description _EL property+ _EL (note)? building
|
||||
title: "#" /(?! ).+(?<! )/ _NL // not starting or ending with a space
|
||||
|
||||
description: "_" /(?! ).+(?<![ _])/ "_" _NL // single line not ending with underscore
|
||||
@ -9,9 +9,9 @@ _value : quoted_value | unquoted_value
|
||||
quoted_value : /\".+?\"/ // with quotation marks, can contain commas
|
||||
unquoted_value : /(?![ \"])[^,\n]+(?<![ \"])/ // cannot contain commas, cannot start or end with quotation mark
|
||||
|
||||
note.3: /(?![\-#]).*\n/+ // Unstructured text, not starting with - or #
|
||||
note: /(?![\-#]).*\n/+ // Unstructured text, not starting with - or #
|
||||
|
||||
building: "## Building" _NL property* note? // the "building" section
|
||||
building: "## Building" _NL (_EL property+)? (_EL note)? _EL* // the "building" section
|
||||
|
||||
|
||||
_NUMBER: /[0-9]+/
|
||||
@ -20,7 +20,6 @@ CR : /\r/
|
||||
LF : /\n/
|
||||
_NL : CR? LF
|
||||
WS : (" "|/\t/)+
|
||||
_EL.2 : /^$\n/m
|
||||
_EL : /^$\n/m
|
||||
|
||||
%ignore WS
|
||||
%ignore _EL
|
||||
%ignore WS
|
@ -605,7 +605,6 @@ def write_entries(entries):
|
||||
"""
|
||||
|
||||
# iterate over all entries
|
||||
entries = entries[:20]
|
||||
for entry in entries:
|
||||
write_entry(entry)
|
||||
|
||||
@ -641,29 +640,32 @@ def create_entry_content(entry):
|
||||
for field in valid_fields:
|
||||
field_name = field.lower()
|
||||
if field_name in entry:
|
||||
content += '- {}: {}\n'.format(field, ', '.join(entry[field_name]))
|
||||
c = entry[field_name]
|
||||
c = ['"{}"'.format(x) if ',' in x else x for x in c]
|
||||
content += '- {}: {}\n'.format(field, ', '.join(c))
|
||||
content += '\n'
|
||||
|
||||
# if there is a note, insert it
|
||||
if 'note' in entry:
|
||||
content += entry['note'] + '\n'
|
||||
content += entry['note']
|
||||
|
||||
# building header
|
||||
content += '## Building\n\n'
|
||||
content += '## Building\n'
|
||||
|
||||
# building properties if present
|
||||
has_properties = False
|
||||
for field in valid_building_fields:
|
||||
field_name = field.lower()
|
||||
if field_name in entry['building']:
|
||||
has_properties = True
|
||||
if not has_properties:
|
||||
has_properties = True
|
||||
content += '\n'
|
||||
content += '- {}: {}\n'.format(field, ', '.join(entry['building'][field_name]))
|
||||
|
||||
# if there is a note, insert it
|
||||
if 'note' in entry['building']:
|
||||
if has_properties:
|
||||
content += '\n'
|
||||
content += entry['building']['note'] + '\n'
|
||||
content += '\n'
|
||||
content += entry['building']['note']
|
||||
|
||||
return content
|
||||
|
||||
|
Reference in New Issue
Block a user