def _setup_specs(self) -> None: """ Will get run multiple times - as more info trickles in! """ # record specs: records = self.nconfig.records.split(',') exrecords = self.nconfig.exrecords.split( ',') if self.nconfig.exrecords else [] self.rec_specs = slicer.Specifications('incl_rec', records, infile_item_count=self.rec_cnt) self.exrec_specs = slicer.Specifications( 'excl_rec', exrecords, infile_item_count=self.rec_cnt) # col specs: records = self.nconfig.columns.split(',') exrecords = self.nconfig.excolumns.split( ',') if self.nconfig.excolumns else [] self.col_specs = slicer.Specifications('incl_col', records, infile_item_count=self.col_cnt, header=self.nconfig.header) self.excol_specs = slicer.Specifications( 'excl_col', exrecords, infile_item_count=self.col_cnt, header=self.nconfig.header)
def test_all_conditions(self): self.runner(['account_id'], loc=0, item_count=80, header=['account_id', 'cust_id', 'zip']) self.sp = mod.SpecProcessor(self.specs) assert self.sp.index == [0] # Single Cols specs = mod.Specifications(spec_type='incl_rec', specs_strings=['5'], infile_item_count=80) assert self.sp._spec_item_check(specs.specs_final[0], 5) # Ranges: specs = mod.Specifications(spec_type='incl_rec', specs_strings=['5:10:1']) assert self.sp._spec_item_check(specs.specs_final[0], 5) assert self.sp._spec_item_check(specs.specs_final[0], 9) assert self.sp._spec_item_check(specs.specs_final[0], 10) is False
def simple_runner(self, spec_strings, loc, spec_type='incl_rec', item_count=4, header=None): """ Creates the Spec Processor object with default settings for the specification and record length. """ specifications = mod.Specifications(spec_type, specs_strings=spec_strings, header=header, infile_item_count=item_count) self.sp = mod.SpecProcessor(specifications) return self.sp.specs_evaluator(loc)
def setup_spec(self, specs_strings, spec_type='incl_rec', header: List[str] = None, item_count=100): if header: header_obj = csvhelper.Header() header_obj.load_from_list(field_names=header) else: header_obj = None self.spec = mod.Specifications(spec_type=spec_type, specs_strings=specs_strings, header=header_obj, infile_item_count=item_count)
def setup_spec(self, specs_strings, spec_type='incl_rec', item_count=sys.maxsize, item_max=mod.MAX_INDEX_REC_CNT): item_count = 100 self.spec = mod.Specifications(spec_type=spec_type, specs_strings=specs_strings, header=None, infile_item_count=item_count) self.indexer = mod.Indexer(self.spec.specs_final) self.indexer._item_max = item_max self.indexer.builder() self.index = self.indexer.index
def runner(self, spec_strings, spec_type='incl_rec', item_count=80, header=None): """ Creates the Spec Processor object with default settings for the specification and record length. """ if header: header_obj = csvhelper.Header() header_obj.load_from_list(field_names=header) else: header_obj = None self.specs = mod.Specifications(spec_type, specs_strings=spec_strings, header=header_obj, infile_item_count=item_count)
def setup_spec(self, specs_strings, spec_type='incl_rec'): self.spec = mod.Specifications(spec_type=spec_type, specs_strings=specs_strings, header=None, infile_item_count=100)