Internal function used to generate the Records from
    their template.
15564
def _GenNetflowRecordV9(cls, lengths_list):
    
    _fields_desc = []
    for j, k in lengths_list:
        _f_data = NetflowV9TemplateFieldDecoders.get(k, None)
        _f_type, _f_args = (
            _f_data if isinstance(_f_data, tuple) else (_f_data, [])
        )
        _f_kwargs = {}
        if _f_type:
            if issubclass(_f_type, _AdjustableNetflowField):
                _f_kwargs["length"] = j
            _fields_desc.append(
                _f_type(
                    NetflowV910TemplateFieldTypes.get(k, "unknown_data"),
                    0, *_f_args, **_f_kwargs
                )
            )
        else:
            _fields_desc.append(
                _CustomStrFixedLenField(
                    NetflowV910TemplateFieldTypes.get(k, "unknown_data"),
                    b"", length=j
                )
            )

    # This will act exactly like a NetflowRecordV9, but has custom fields
    class NetflowRecordV9I(cls):
        fields_desc = _fields_desc
        match_subclass = True
    NetflowRecordV9I.name = cls.name
    NetflowRecordV9I.__name__ = cls.__name__
    return NetflowRecordV9I
1373440
@Override
    public List<InputRecord> generate() throws Exception {
        List<InputRecord> result = new ArrayList<InputRecord>();
        InputRecord testRecord = (InputRecord) this.getInput().clone();
        this.validate();
        for (String value : values) {
            result.add(
                    new InputRecord(
                            testRecord.getName(),
                            testRecord.getType(),
                            value.replaceAll("\\\\;", ";"),
                            testRecord.getCondition(),
                            true));
        }
        String negativeValue = "";
        for (String value : values) {
            negativeValue = StringUtils.reverse(negativeValue.concat(value.replaceAll("\\\\;", ";")));
            if (!values.contains(negativeValue)) {
                result.add(
                    new InputRecord(
                            testRecord.getName(),
                            testRecord.getType(),
                            negativeValue,
                            testRecord.getCondition(),
                            false));
                break;
            }
        }
        return result;
    }
746378
def loadRecords(self, records):
        
        self.setChildIndicatorPolicy(self.DontShowIndicatorWhenChildless)
        self._loaded = True
        
        if records is None:
            return
        
        # load sub-groups if desired
        if self._nextLevels and RecordSet.typecheck(records):
            level = self._nextLevels[0]
            sublevels = self._nextLevels[1:]
            
            records = records.grouped(level)
            
        elif RecordSet.typecheck(records):
            sublevels = None
            records = records.all()
        
        else:
            sublevels = None
        
        # load a child set of groups
        if type(records) == dict:
            try:
                generator = self.treeWidget().createGroupItem
                cls = None
            except AttributeError:
                generator = None
                cls = type(self)
                
            for subgroup, subrecords in records.items():
                if generator:
                    generator(subgroup, subrecords, sublevels, self)
                elif cls:
                    cls(self, subgroup, subrecords, sublevels)
        
        # load records
        else:
            try:
                generator = self.treeWidget().createRecordItem
                cls = None
            except AttributeError:
                generator = None
                cls = XOrbRecordItem
            
            cls = self.treeWidget().createRecordItem
            for record in records:
                if generator:
                    generator(record, self)
                elif cls:
                    cls(self, record)
550031
def gen_template_files(path):
    "  "

    path = path.rstrip(op.sep)
    for root, _, files in walk(path):
        for f in filter(lambda x: not x in (TPLNAME, CFGNAME), files):
            yield op.relpath(op.join(root, f), path)
1091247
def generate
      template = File.read(template_path)
      cloudfile = ERB.new(template, nil, "%<>-")
      cloudfile.result(binding)
    end
160612
def _create_record(self, rtype, name, content):
        """"""
        return self._change_record_sets('CREATE', rtype, name, content)
857364
def build_records(amount, per_query, &block)
      amount.times do
        index = last_id_in_database + @records.size + 1
        record = Record.new(@model_class, index)
        @records << record
        block.call(record, index) if block
        save_records if @records.size >= per_query
      end
    end
541793
@Override
  public GeneratedCode generate(ClassTemplateSpec templateSpec) {

    String code;
    TSProperties TSProperties = globalConfig.lookupTSProperties(templateSpec);
    if (TSProperties.omit) return null;

    TSSyntax syntax = new TSSyntax(TSProperties);
    try {
      if (templateSpec instanceof RecordTemplateSpec) {
        code = engine.render("rythm-ts/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec));
      } else if (templateSpec instanceof EnumTemplateSpec) {
        code = engine.render("rythm-ts/enum.txt", syntax.new TSEnumSyntax((EnumTemplateSpec) templateSpec));
      } else if (templateSpec instanceof UnionTemplateSpec) {
        code = engine.render("rythm-ts/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec));
      } else if (templateSpec instanceof TyperefTemplateSpec) {
        TyperefTemplateSpec typerefSpec = (TyperefTemplateSpec) templateSpec;
        code = engine.render("rythm-ts/typeref.txt", syntax.TSTyperefSyntaxCreate(typerefSpec));
      } else if (templateSpec instanceof FixedTemplateSpec) {
        code = engine.render("rythm-ts/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec));
      } else {
        return null; // Indicates that we are declining to generate code for the type (e.g. map or array)
      }
    } catch (RythmException e) {
      throw new RuntimeException(
        "Internal error in generator while processing " + templateSpec.getFullName(), e);
    }
    TSCompilationUnit compilationUnit =
        new TSCompilationUnit(
            templateSpec.getFullName(), "");
    code = formatter.format(code);
    return new GeneratedCode(compilationUnit, code);
  }
45568
function(records) {
    var self = this.chain()
    var relation = self.getInternal('relation')
    var parentRecord = self.getInternal('relation_to')

    if (!records) return self
    if (!Array.isArray(records)) records = [records]

    // build a map to check if existing records were added - via primary key
    const primaryKeys = self.definition.primaryKeys
    const map = {}
    self.forEach(function(record) {
      var mapKey = []
      primaryKeys.forEach(function(key) {
        if (record[key]) mapKey.push(record[key])
      })
      if (mapKey.length > 0) map[mapKey.join('|')] = record
    })

    records.forEach(function(record) {
      var fromKeys = false
      var mapKey = []

      if (record) {
        // check if `records` is a primitive, or an array of primitives with the same amount of elements as our primary keys
        if (
          typeof record !== 'object' ||
          (Array.isArray(record) &&
            record.length === primaryKeys.length &&
            typeof record[0] !== 'object')
        ) {
          // not a record/object... so it must be a primary key!
          if (self.options.polymorph)
            throw new Error('Polymorphic relations need to add a record!')

          var keys = record
          const tmpRecord = {}

          if (!Array.isArray(keys)) keys = [keys]

          primaryKeys.forEach(function(key, index) {
            if (keys[index]) {
              tmpRecord[key] = keys[index]
              mapKey.push(keys[index])
            }
          })

          if (mapKey.length > 0 && map[mapKey.join('|')]) {
            // found a record no update needed, because we only got the id...
            return
          }

          record = tmpRecord
          fromKeys = true
        }

        primaryKeys.forEach(function(key) {
          if (record[key]) mapKey.push(record[key])
        })

        if (mapKey.length > 0 && map[mapKey.join('|')]) {
          // found a record for update!
          map[mapKey.join('|')].set(record)
          return
        }

        const originalInput = record
        // convert object to a record
        if (self.options.polymorph) {
          if (record.model && !(record instanceof record.model))
            throw new Error(
              'Record/Model instance expected in polymorphic relation!'
            )
        } else {
          if (!(record instanceof self.model)) record = self.model.new(record)
        }

        record.__chainedModel = self

        if (fromKeys) {
          record._exists()
        } else {
          if (mapKey.length > 0 && mapKey.length === primaryKeys.length) {
            record._exists()
            if (!(originalInput instanceof self.model)) {
              // set changes. if for example the record is not loaded, but we now have the primary keys. Only the given fields are changes.
              // all fields that are not present in the original input, must not be changed, because we dont now their value.
              Object.keys(originalInput).forEach(function(key) {
                // ignore primary keys
                if (primaryKeys.indexOf(key) === -1) {
                  record.changes[key] = [undefined, originalInput[key]]
                }
              })
            }
          }
        }

        // a new one
        self.push(record)

        if (relation && parentRecord) {
          if (record && typeof relation.add === 'function') {
            relation.add.call(self, parentRecord, record)
          }
        }
      }
    })

    return self
  }
961099
def include_from_file(records, handle):
    
    ids = set(i.strip() for i in handle)

    for record in records:
        if record.id.strip() in ids:
            yield record
218146
def recordset(method):
        """"""
        def wrapper(self, *args, **kwargs):
            if self.__records__ is None:
                raise ValidationError(
                    'There are no records in the set.',
                )
            return method(self, *args, **kwargs)
        return Api.model(wrapper)
919361
def generate_records(self, infile):
        

        state = 0
        record = {}

        for item in self.generate_lines(infile):

            line = item['line']
            heading = item['heading']
            
            # any Markdown heading is just a caption, no image
            if heading:
                record['heading'] = True
                record['caption'] = line[1:].strip()

                state = 'caption'
                continue

            if not line[0].isspace():
                # at a potential image
                if state == 'caption':
                    yield record
                    record = {}
                    state = 0

            if state == 'caption':
                record['caption'] += '\n' + line[:-1]
                continue

            fields = line.split(',')

            # nothing there, carry on
            if not fields: continue

            image = fields[0].strip()

            if not image: continue

            record['image'] = image

            try:
                time = float(fields[1])
            except:
                time = 0

            record['time'] = time

            try:
                caption = fields[2].strip()
            except:
                caption = None

            if caption:
                record['caption'] = caption

            # yield it if we have anything
            if record:
                yield record
                record = {}
1260018
def head(records, head):
    
    logging.info('Applying _head generator: '
                 'limiting results to top ' + head + ' records.')

    if head == '-0':
        for record in records:
            yield record
    elif '-' in head:
        with _record_buffer(records) as r:
            record_count = sum(1 for record in r())
            end_index = max(record_count + int(head), 0)
            for record in itertools.islice(r(), end_index):
                yield record
    else:
        for record in itertools.islice(records, int(head)):
            yield record
614020
def generate(debug = false)
      decorator = debug ? Fixy::Decorator::Debug : Fixy::Decorator::Default
      output = ''
      current_position = 1
      current_record = 1

      while current_position <= self.class.record_length do

        field = record_fields[current_position]
        raise StandardError, "Undefined field for position #{current_position}" unless field

        # We will first retrieve the value, then format it
        method          = field[:name]
        value           = send(method)
        formatted_value = format_value(value, field[:size], field[:type])
        formatted_value = decorator.field(formatted_value, current_record, current_position, method, field[:size], field[:type])

        output << formatted_value
        current_position = field[:to] + 1
        current_record += 1
      end

      # Documentation mandates that every record ends with new line.
      output << line_ending

      # All ready. In the words of Mr. Peters: "Take it and go!"
      decorator.record(output)
    end
1174074
def save_records(self, records):
        '''
        
        '''
        for record in records:
            if not isinstance(record, Record):
                record = Record(*record)
            self.save_record(*record)
604896
def records(self):
        
        output = tempfile.NamedTemporaryFile(suffix='.json')
        try:
            log.info("Loading table from (%s)...", self._obj)
            shutil.copyfileobj(self.fh(), output)
            output.seek(0)

            for line in output.file:
                yield json.loads(line, object_hook=json_hook)

        finally:
            try:
                output.close()
            except:
                pass
70634
def eachRecord( records = @records )
      if records and block_given?
         records.each { |record|
            if record.is_a?( REXML::Element) and record.name == "record"
               @record = record
               yield record
            end
         }
      end
      nil
   end