def add(*args): '''Add a new Pydea.''' if not stream.exists: bumpy.abort('Not a Pydea stream') now = str(int(time.time())) datetime = time.strftime(FMT_DATETIME, time.localtime()) full_path = os.path.join(stream.path, now + '.md') if args: # has arguments contents = '\n\n'.join(args).strip() else: # no arguments, open $EDITOR desc, name = tempfile.mkstemp(suffix='.md', text = True) os.system('{} "{}"'.format(CONFIG['editor'], name)) with open(name) as arg: contents = arg.read().strip() if contents: with open(full_path, 'w+') as temp: temp.write('* datetime = {}\n\n'.format(datetime)) temp.write(contents) print 'Added Pydea ' + now else: bumpy.abort('Pydea contents were empty')
def init(**kwargs): '''Initialize a Pydea stream.''' if stream.exists: bumpy.abort('Already a Pydea stream') if not os.path.exists(stream.path): os.makedirs(stream.path) with open(os.path.join(stream.path, 'meta.md'), 'w+') as temp: temp.write('* title = {}\n'.format(kwargs['title'])) temp.write('* tags = {}\n'.format(kwargs['tags'])) print 'Created empty Pydea stream'
def migrate(start=0.1, end=0.2): start, end = float(start), float(end) if end <= start: b.abort("Unable to migrate to a previous version") print "Migrating database from {} to {}".format(start, end)
def edit(): '''Edit the Pydea metadata.''' if not stream.exists: bumpy.abort('Not a Pydea stream') os.system('{} "{}"'.format(CONFIG['editor'], stream.metafile))
def show(): '''View the Pydea stream.''' if not stream.exists: bumpy.abort('Not a Pydea stream') print stream
def check(): contests = os.listdir('contests') for contest in contests: if not os.path.exists(os.path.join('contests', contest, 'data.db')): b.abort('Contest "{0}" does not have a database. Please initialize it first:\n\tbump db.init {0}'.format(contest))