Return a Github-flavored markdown table of
information about the model's column structure
17230
public function columnsDoc()
    {
        $ret = str_pad('Name', 25, ' ') . '|' . str_pad('Type', 15, ' ') . '|Info' . "\n";
        $ret .= str_repeat('-', 25) . '|' . str_repeat('-', 15) . '|' . str_repeat('-', 10) . "\n";
        foreach ($this->columns as $name => $info) {
            $ret .= str_pad($name, 25, ' ') . '|';
            $ret .= str_pad($info['type'], 15, ' ') . '|';
            if (isset($info['primary_key'])) {
                $ret .= 'PK ';
            }
            if (isset($info['index'])) {
                $ret .= 'Indexed ';
            }
            if (isset($info['increment'])) {
                $ret .= 'Increment ';
            }
            if (isset($info['default'])) {
                $ret .= 'Default=' . $info['default'];
            }
            $ret .= "\n";
        }

        return $ret;
    }
30190
def gen_columns_info(engine: Engine,
                     tablename: str) -> Generator[SqlaColumnInspectionInfo,
                                                  None, None]:
    
    # Dictionary structure: see
    # http://docs.sqlalchemy.org/en/latest/core/reflection.html#sqlalchemy.engine.reflection.Inspector.get_columns  # noqa
    insp = Inspector.from_engine(engine)
    for d in insp.get_columns(tablename):
        yield SqlaColumnInspectionInfo(d)
738879
def _fieldnames_to_colnames(model_cls, fieldnames):
        """"""
        get_field = model_cls._meta.get_field
        fields = map(get_field, fieldnames)
        return {f.column for f in fields}
939815
def parse_model_table_file(path, f):
    

    for line in f:
        line, _, comment = line.partition('#')
        line = line.strip()
        if line == '':
            continue

        yield line
629428
def get_column_names(engine: Engine, tablename: str) -> List[str]:
    
    return [info.name for info in gen_columns_info(engine, tablename)]
1028264
def to_dict(self):
        """"""
        data = model_to_dict(self, exclude=['id'])
        data['title'] = unicode(self)
        data['slug'] = self.slug
        data['release_date'] = self.release_date.date().isoformat()
        data['created'] = self.created.isoformat()
        data['modified'] = self.modified.isoformat()
        new_features, known_issues = self.notes(public_only=False)
        for note in known_issues:
            note.tag = 'Known'
        data['notes'] = [n.to_dict(self) for n in chain(new_features, known_issues)]
        return data
414897
def model_inspect(obj):
        '''
        
        '''
        # Prepare the information object
        info = {}
        if hasattr(obj, '_meta'):
            info['verbose_name'] = getattr(obj._meta, 'verbose_name', None)
        else:
            info['verbose_name'] = None

        # Get info from the object
        if hasattr(obj, 'model') and obj.model:
            model = obj.model
        else:
            model = obj.__class__

        namesp = str(model)
        namesp = namesp.replace("<class ", "").replace(">", "").replace("'", "").split(".")

        # Remember information
        info['appname'] = namesp[-3]
        info['modelname'] = namesp[-1]
        info['model'] = model

        # Return the info
        return info
9501
def columnInfo(self):
        
        code = "proc contents data=" + self.libref + '.' + self.table + ' ' + self._dsopts() + ";ods select Variables;run;"

        if self.sas.nosub:
            print(code)
            return

        if self.results.upper() == 'PANDAS':
            code = "proc contents data=%s.%s %s ;ods output Variables=work._variables ;run;" % (self.libref, self.table, self._dsopts())
            pd = self._returnPD(code, '_variables')
            pd['Type'] = pd['Type'].str.rstrip()
            return pd

        else:
            ll = self._is_valid()
            if self.HTML:
                if not ll:
                    ll = self.sas._io.submit(code)
                if not self.sas.batch:
                    self.sas.DISPLAY(self.sas.HTML(ll['LST']))
                else:
                    return ll
            else:
                if not ll:
                    ll = self.sas._io.submit(code, "text")
                if not self.sas.batch:
                    print(ll['LST'])
                else:
                    return ll
255505
def markdown(self,md,project):
        
        if len(self.doc) > 0:
            if len(self.doc) == 1 and ':' in self.doc[0]:
                words = self.doc[0].split(':')[0].strip()
                if words.lower() not in ['author','date','license','version','category','summary','deprecated','display','graph']:
                    self.doc.insert(0,'')
                self.doc.append('')
            self.doc = '\n'.join(self.doc)
            self.doc = md.convert(self.doc)
            self.meta = md.Meta
            md.reset()
            md.Meta = {}
        else:
            if self.settings['warn'].lower() == 'true' and self.obj != 'sourcefile' and self.obj != 'genericsource':
                #TODO: Add ability to print line number where this item is in file
                print('Warning: Undocumented {} {} in file {}'.format(self.obj, self.name, self.hierarchy[0].name))
            self.doc = ""
            self.meta = {}

        if self.parent:
            self.display = self.parent.display

        #~ print (self.meta)
        for key in self.meta:
            #~ print(key, self.meta[key])
            if key == 'display':
                tmp = [ item.lower() for item in self.meta[key] ]
                if type(self) == FortranSourceFile:
                    while 'none' in tmp:
                        tmp.remove('none')
                if len(tmp) == 0:
                    pass
                elif 'none' in tmp:
                    self.display = []
                elif 'public' not in tmp and 'private' not in tmp and 'protected' not in tmp:
                    pass
                else:
                    self.display = tmp
            elif len(self.meta[key]) == 1:
                self.meta[key] = self.meta[key][0]
            elif key == 'summary':
                self.meta[key] = '\n'.join(self.meta[key])
        if hasattr(self,'num_lines'): self.meta['num_lines'] = self.num_lines

        self.doc = ford.utils.sub_macros(ford.utils.sub_notes(self.doc),self.base_url)

        if 'summary' in self.meta:
            self.meta['summary'] = md.convert(self.meta['summary'])
            self.meta['summary'] = ford.utils.sub_macros(ford.utils.sub_notes(self.meta['summary']),self.base_url)
        elif PARA_CAPTURE_RE.search(self.doc):
            if self.get_url() == None:
                # There is no stand-alone webpage for this item (e.g.,
                # an internal routine in a routine, so make the whole
                # doc blob appear, without the link to "more..."
                self.meta['summary'] = self.doc
            else:
                self.meta['summary'] = PARA_CAPTURE_RE.search(self.doc).group()
        else:
            self.meta['summary'] = ''
        if self.meta['summary'].strip() != self.doc.strip():
            self.meta['summary'] += '<a href="{}" class="pull-right"><emph>Read more&hellip;</emph></a>'.format(self.get_url())
        if 'graph' not in self.meta:
            self.meta['graph'] = self.settings['graph']
        else:
            self.meta['graph'] = self.meta['graph'].lower()
        if 'graph_maxdepth' not in self.meta:
            self.meta['graph_maxdepth'] = self.settings['graph_maxdepth']
        if 'graph_maxnodes' not in self.meta:
            self.meta['graph_maxnodes'] = self.settings['graph_maxnodes']

        if self.obj == 'proc' or self.obj == 'type' or self.obj == 'program':
            if 'source' not in self.meta:
                self.meta['source'] = self.settings['source'].lower()
            else:
                self.meta['source'] = self.meta['source'].lower()
            if self.meta['source'] == 'true':
                if self.obj == 'proc':
                    obj = self.proctype.lower()
                else:
                    obj = self.obj
                regex = re.compile(self.SRC_CAPTURE_STR.format(obj,self.name), re.IGNORECASE|re.DOTALL|re.MULTILINE)
                match = regex.search(self.hierarchy[0].raw_src)
                if match:
                    self.src = highlight(match.group(),FortranLexer(),HtmlFormatter())
                else:
                    self.src = ''
                    if self.settings['warn'].lower() == 'true':
                        print('Warning: Could not extract source code for {} {} in file {}'.format(self.obj, self.name, self.hierarchy[0].name))

        if self.obj == 'proc':
            if 'proc_internals' not in self.meta:
                self.meta['proc_internals'] = self.settings['proc_internals'].lower()
            else:
                self.meta['proc_internals'] = self.meta['proc_internals'].lower()

        # Create Markdown
        for item in self.iterator('variables', 'modules', 'submodules', 'common',
                                   'subroutines', 'modprocedures', 'functions',
                                   'interfaces', 'absinterfaces', 'types',
                                   'programs', 'blockdata', 'boundprocs',
                                   'finalprocs', 'args', 'enums'):
            if isinstance(item, FortranBase):
                item.markdown(md, project)
        if hasattr(self,'retvar'):
            if self.retvar:
                if isinstance(self.retvar, FortranBase):
                    self.retvar.markdown(md, project)
        if hasattr(self,'procedure'):
            if isinstance(self.procedure, FortranBase):
                self.procedure.markdown(md, project)
        return
849258
function getColumnDetails(column) {
    logger.debug('column details are calculated for: %s', column.name());
    var result = filterAttributes({
        source              : 'generator',
        accessorName        : getSpecificConfig(column.table().name(), 'generate.columnAccessorCamelCase') ? inflection.camelize(inflection.underscore(column.name()), true) : column.name(),
        name                : column.name(),
        primaryKey          : column.isPrimaryKey(),
        autoIncrement       : column.isAutoIncrement() && getSpecificConfig(column.table().name(), 'generate.columnAutoIncrement') ? true : undefined,
        allowNull           : column.allowNull(),
        defaultValue        : getSpecificConfig(column.table().name(), 'generate.columnDefault') && column.default() !== null ? clearDefaultValue(column.default()) : undefined,
        unique              : column.unique(),
        comment             : getSpecificConfig(column.table().name(), 'generate.columnDescription') ? column.description() : undefined,
        references          : column.foreignKeyConstraint() ? getModelNameFor(column.foreignKeyConstraint().referencesTable()) : undefined,
        referencesKey       : column.foreignKeyConstraint() ? column.foreignKeyConstraint().foreignKey(0).name() : undefined,
        onUpdate            : column.onUpdate(),
        onDelete            : column.onDelete()
    });

    result.type = sequelizeType(column, getSpecificConfig(column.table().name(), 'generate.dataTypeVariable')); // To prevent type having quotes.
    //result.type = column.sequelizeType(getSpecificConfig(column.table().name(), 'generate.dataTypeVariable')); // To prevent type having quotes.
    return result;
}
647587
def convert_table(app, docname, source):
    """"""
    num_tables = 0
    for i,j in enumerate(source):
        table = []
        output = ''
        in_table = False
        for l in j.split('\n'):
            r = l.strip()
            if r.startswith('|'):
                table.append(r)
                in_table = True
            else:
                if in_table is True:
                    converted = _convert_md_table_to_rst(table)
                    if converted is '':
                        print("Failed to convert the markdown table")
                        print(table)
                    else:
                        num_tables += 1
                    output += converted
                    in_table = False
                    table = []
                output += l + '\n'
        source[i] = output
    if num_tables > 0:
        print('Converted %d tables in %s' % (num_tables, docname))
1068696
def fields(self):
        
        process_markdown = ("fields" in self._raw.get("mrkdwn_in", []))
        fields = self._raw.get("fields", [])
        if fields:
            logging.debug("Rendering with markdown markdown %s for %s", process_markdown, fields)
        return [
            {"title": e["title"], "short": e["short"], "value": self._formatter.render_text(e["value"], process_markdown)}
            for e in fields
        ]
847411
def _build_table(self, info, order, max_col_len=40, only_changed=False):
        

        info_dict, bounds_dict = {}, {}
        (params, val_dict, changed) = info
        col_widths = dict((k,0) for k in order)

        for name, p in params.items():
            if only_changed and not (name in changed):
                continue

            constant = 'C' if p.constant else 'V'
            readonly = 'RO' if p.readonly else 'RW'
            allow_None = ' AN' if hasattr(p, 'allow_None') and p.allow_None else ''

            mode = '%s %s%s' % (constant, readonly, allow_None)
            info_dict[name] = {'name': name, 'type':p.__class__.__name__,
                               'mode':mode}

            if hasattr(p, 'bounds'):
                lbound, ubound = (None,None) if p.bounds is None else p.bounds

                mark_lbound, mark_ubound = False, False
                # Use soft_bounds when bounds not defined.
                if hasattr(p, 'get_soft_bounds'):
                    soft_lbound, soft_ubound = p.get_soft_bounds()
                    if lbound is None and soft_lbound is not None:
                        lbound = soft_lbound
                        mark_lbound = True
                    if ubound is None and soft_ubound is not None:
                        ubound = soft_ubound
                        mark_ubound = True

                if (lbound, ubound) != (None,None):
                    bounds_dict[name] = (mark_lbound, mark_ubound)
                    info_dict[name]['bounds'] = '(%s, %s)' % (lbound, ubound)

            value = repr(val_dict[name])
            if len(value) > (max_col_len - 3):
                value = value[:max_col_len-3] + '...'
            info_dict[name]['value'] = value

            for col in info_dict[name]:
                max_width = max([col_widths[col], len(info_dict[name][col])])
                col_widths[col] = max_width

        return self._tabulate(info_dict, col_widths, changed, order, bounds_dict)
174754
function columnInfo() {
    var column = this.single.columnInfo;
    return {
      sql: 'select * from information_schema.columns where table_name = ? and table_catalog = ?',
      bindings: [this.single.table, this.client.database()],
      output: function output(resp) {
        var out = resp.rows.reduce(function (columns, val) {
          columns[val.column_name] = {
            type: val.data_type,
            maxLength: val.character_maximum_length,
            nullable: val.is_nullable === 'YES',
            defaultValue: val.column_default
          };
          return columns;
        }, {});
        return column && out[column] || out;
      }
    };
  }
788232
def format_for_columns(pkgs, options):
    
    running_outdated = options.outdated
    # Adjust the header for the `pip list --outdated` case.
    if running_outdated:
        header = ["Package", "Version", "Latest", "Type"]
    else:
        header = ["Package", "Version"]

    data = []
    if options.verbose >= 1 or any(dist_is_editable(x) for x in pkgs):
        header.append("Location")
    if options.verbose >= 1:
        header.append("Installer")

    for proj in pkgs:
        # if we're working on the 'outdated' list, separate out the
        # latest_version and type
        row = [proj.project_name, proj.version]

        if running_outdated:
            row.append(proj.latest_version)
            row.append(proj.latest_filetype)

        if options.verbose >= 1 or dist_is_editable(proj):
            row.append(proj.location)
        if options.verbose >= 1:
            row.append(get_installer(proj))

        data.append(row)

    return data, header
579230
def convert_toml_outline_tables(parsed):
    """"""
    def convert_tomlkit_table(section):
        for key, value in section._body:
            if not key:
                continue
            if hasattr(value, "keys") and not isinstance(value, tomlkit.items.InlineTable):
                table = tomlkit.inline_table()
                table.update(value.value)
                section[key.key] = table

    def convert_toml_table(section):
        for package, value in section.items():
            if hasattr(value, "keys") and not isinstance(value, toml.decoder.InlineTableDict):
                table = toml.TomlDecoder().get_empty_inline_table()
                table.update(value)
                section[package] = table

    is_tomlkit_parsed = isinstance(parsed, tomlkit.container.Container)
    for section in ("packages", "dev-packages"):
        table_data = parsed.get(section, {})
        if not table_data:
            continue
        if is_tomlkit_parsed:
            convert_tomlkit_table(table_data)
        else:
            convert_toml_table(table_data)

    return parsed
466106
def specs_to_table_string(specs_to_be_shown)
      whitespace_padding = 3
      table = []
      attrs_to_be_shown = {
        name:        SpecTableAttr.new('Name',      true,  'Name'.length + whitespace_padding),
        symbol:      SpecTableAttr.new('Symbol',    false, 'Symbol'.length + whitespace_padding),
        mode:        SpecTableAttr.new('Mode',      true,  'Mode'.length + whitespace_padding),
        type:        SpecTableAttr.new('Type',      true,  'Type'.length + whitespace_padding),
        sub_type:    SpecTableAttr.new('Sub-Type',  false, 'Sub-Type'.length + whitespace_padding),
        # spec SpecTableAttribute :description is called parameter in the spec table output to match historical docs
        description: SpecTableAttr.new('Parameter', false, 'Parameter'.length + whitespace_padding),
        min:         SpecTableAttr.new('Min',       false, 'Min'.length + whitespace_padding),
        typ:         SpecTableAttr.new('Typ',       false, 'Typ'.length + whitespace_padding),
        max:         SpecTableAttr.new('Max',       false, 'Max'.length + whitespace_padding),
        unit:        SpecTableAttr.new('Unit',      false, 'Unit'.length + whitespace_padding),
        audience:    SpecTableAttr.new('Audience',  false, 'Audience'.length + whitespace_padding)
        # notes:       SpecTableAttr.new('Notes',     false, 'Notes'.length + whitespace_padding)
      }
      # Calculate the padding needed in the spec table for the longest attr of all specs
      specs_to_be_shown.each do |spec|
        attrs_to_be_shown.each do |attr_name, attr_struct|
          unless spec.send(attr_name).nil?
            if spec.send(attr_name).class == Origen::Specs::Spec::Limit
              next if spec.send(attr_name).value.nil?
              current_padding = spec.send(attr_name).value.to_s.length + whitespace_padding
            else
              current_padding = spec.send(attr_name).to_s.length + whitespace_padding
            end
            attr_struct.padding = current_padding if attr_struct.padding < current_padding
            attr_struct.show = true # We found real data for this attr on at least one spec so show it in the spec table
          end
        end
      end
      # Now that each spec attribute padding construct the spec table header
      header = ''
      attrs_to_be_shown.each do |_attr_name, attr_struct|
        next if attr_struct.show == false
        header += "| #{attr_struct.table_text}".ljust(attr_struct.padding)
      end
      header += '|'
      ip_header = "| IP: #{specs_to_be_shown.first.ip_name} ".ljust(header.length - 1)
      ip_header += '|'
      table << '=' * header.length
      table << ip_header
      table << '=' * header.length
      table << header
      table << '-' * header.length
      # Create the data lines in the spec table
      specs_to_be_shown.each do |spec|
        data = ''
        attrs_to_be_shown.each do |attr_name, attr_struct|
          next if attr_struct.show == false
          if spec.send(attr_name).class == Origen::Specs::Spec::Limit
            data += "| #{spec.send(attr_name).value}".ljust(attr_struct.padding)
          else
            data += "| #{spec.send(attr_name)}".ljust(attr_struct.padding)
          end
        end
        table << data += '|'
      end
      table << '-' * header.length
      table.flatten.join("\n")
    end