def __init__(self, item, fields, filename, enumerate_rows=False, dir_=None): full_filename = os.path.join(dir_, filename) self.item = item self.fields = fields self.filename = full_filename self.enumerate_rows = enumerate_rows self.list = [] self.dict = {} self.field_list = fields.split() self.first_field_name = self.field_list[0] self.timestamp = "%s, %s" % (fmt.current_date_yymd(), fmt.current_time_hm()) # enumerate_rows = create artificial key, to allow duplicates # of first field (which otherwise is taken as a key) if enumerate_rows: self.fields = "z_rowno_ " + self.fields self.field_list = self.fields.split() self.index_field_name = self.field_list[0] self.field_count = len(self.field_list) if not os.path.exists(self.filename): e = "Config %s missing file %s" % (item, full_filename) raise Exception(e) self.import_csv()
def csv_header_instructions(count, item, filename): s1 = """\ # Saved %s Green Elk %ss on %s # in file named %s """ s2 = """\ # Instructions: # - edit in your favourite text editor # - alternatively, use a spreadsheet (OOo tested in Excel mode) # - sort and edit as desired # - save the file again as csv # - upon import, empty rows and # comment rows will be ignored # - the # and empty row layouting is hence only to give you an overview # of a freshly created csv file # # On formats: # - do retain the first line with field names unchanged (required by program) # - UTF8 is to be used; едц should show as aao with ring and dots # (if not, change your editor format or face problems later) # - Text fields with commas, double " and single ' quotes will be # "safe quoted", i.e. surrounded by " and the " itself is doubled # (courtesy of Python import csv) """ timestamp = "%s, %s" % (fmt.current_date_yymd(), fmt.current_time_hm()) return s1 % (count, item, timestamp, filename), s2
def __init__(self, name, verbose=True): self.name = name self.bug_count = 0 self.list = [] self.timestamp = "%s, %s" % (fmt.current_date_yymd(), fmt.current_time_hm())