def make_csv(ics_file, filename): check_exist_file(ics_file) if os.access(filename, os.F_OK): print "fatal: '%s' file is already exist." % filename kill(1) if filename.endswith(".csv") == False: filename = filename + ".csv" ical = Calendar.from_ical(open(ics_file, "r").read()) fp = open(filename, "w") io = StringIO() sys.stdout = io put = sys.stdout.write for event in get_events(ical): # about time start = event.get("dtstart").dt end = event.get("dtend").dt put(start.strftime(date_format) + ",") put(start.strftime(time_format) + ",~," + end.strftime(time_format) + ",") # about time diff delta = relativedelta(end, start) put(u"%dæé" % delta.hours) put((u"%då," if len(str(delta.minutes)) == 2 else u"0%då,") % delta.minutes) # time numberling float_min = float(delta.minutes) / 60 time_num = round(float(delta.hours) + float_min, 2) put("%g," % time_num) # minus 0.5 put("%g\n" % (round(time_num - 0.5, 2))) sys.stdout = sys.__stdout__ fp.write(io.getvalue().encode("SHIFT_JIS")) fp.close()
print commits[index].commithash @parser.option( "show", description="You can show commit difarence", argument_types={"index":int}) def show_diff(index): commits = adjust.get_commits() if index > len(commits)-1: print yellow("this index is over length limit.") return lines = git("show","%s" % commits[index]).split("\n") for line in lines: if line.startswith("+"): print red(line) elif line.startswith("-"): print green(line) elif line.startswith("diff") or line.startswith("index"): print yellow(line) else: print line if __name__ == "__main__": if check_exist_repo() == False: print yellow("There is not git repository!") miniparser.kill(1) parser.parse()
def check_exist_file(path): if os.access(path, os.F_OK): return True else: print "fatal: file not found." kill(1)