forked from jbest/regex-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-template.py
23 lines (22 loc) · 1018 Bytes
/
make-template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import uuid
import yaml
import datetime
"""
Create a new regex repository document template in YAML format named
as [uuid].yaml and stored in the ./regex directory.
"""
regexUUID = uuid.uuid4()
today = datetime.date.today()
templateData = {'regex': 'RegExStringHere', 'updated': str(today),
'description': 'DescriptionHere', 'title': 'TitleHere', 'notes': 'NotesHere',
'created': str(today), 'sampleNonMatches': ['sample1', 'sample2'],
'testString': 'Sample string.', 'version': 'VersionHere', 'testResults': ['result1', 'result2', 'result3'],
'authors': ['author1', 'author2'], 'keywords': ['key1', 'key2'], 'sampleMatches': ['sample1', 'sample2'],
'uuid': str(regexUUID)}
templateString = yaml.dump(templateData, default_flow_style=False)
templateFileName = str(regexUUID) + '.yaml'
#TODO Make sure file name is unique. Yeah, most likely is, but still gotta make sure.
f = open('./regex/' + templateFileName, 'w+')
f.write(templateString)
f.close()
print 'Template created at:', './regex/' + templateFileName