comparison piecrust/commands/builtin/util.py @ 5:474c9882decf

Upgrade to Python 3.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 11 Aug 2014 22:36:47 -0700
parents f485ba500df3
children 617191dec18e
comparison
equal deleted inserted replaced
4:7dc71c2dc9a8 5:474c9882decf
27 destination = ctx.args.destination 27 destination = ctx.args.destination
28 if destination is None: 28 if destination is None:
29 destination = os.getcwd() 29 destination = os.getcwd()
30 30
31 if not os.path.isdir(destination): 31 if not os.path.isdir(destination):
32 os.makedirs(destination, 0755) 32 os.makedirs(destination, 0o755)
33 33
34 config_path = os.path.join(destination, CONFIG_PATH) 34 config_path = os.path.join(destination, CONFIG_PATH)
35 if not os.path.isdir(os.path.dirname(config_path)): 35 if not os.path.isdir(os.path.dirname(config_path)):
36 os.makedirs(os.path.dirname(config_path), 0755) 36 os.makedirs(os.path.dirname(config_path), 0o755)
37 37
38 config_text = yaml.dump({ 38 config_text = yaml.dump({
39 'site': { 39 'site': {
40 'title': "My New Website", 40 'title': "My New Website",
41 'description': "A website recently generated with PieCrust", 41 'description': "A website recently generated with PieCrust",
94 if os.path.exists(page_path): 94 if os.path.exists(page_path):
95 raise Exception("'%s' already exists." % page_path) 95 raise Exception("'%s' already exists." % page_path)
96 96
97 logger.info("Creating page: %s" % os.path.relpath(page_path, app.root_dir)) 97 logger.info("Creating page: %s" % os.path.relpath(page_path, app.root_dir))
98 if not os.path.exists(os.path.dirname(page_path)): 98 if not os.path.exists(os.path.dirname(page_path)):
99 os.makedirs(os.path.dirname(page_path), 0755) 99 os.makedirs(os.path.dirname(page_path), 0o755)
100 with open(page_path, 'w') as f: 100 with open(page_path, 'w') as f:
101 f.write('---\n') 101 f.write('---\n')
102 f.write('title: %s\n' % 'Unknown title') 102 f.write('title: %s\n' % 'Unknown title')
103 f.write('---\n') 103 f.write('---\n')
104 f.write("This is a new page!\n") 104 f.write("This is a new page!\n")