Parse a tab directive
968937
def run(self):
        
        self.assert_has_content()

        group_name = self.content[0]
        self.content.trim_start(2)

        for idx, line in enumerate(self.content.data):
            self.content.data[idx] = '   ' + line

        tab_args = {
            'tab_id': base64.b64encode(
                group_name.encode('utf-8')).decode('utf-8'),
            'group_tab': True
        }

        new_content = [
            '.. tab:: {}'.format(json.dumps(tab_args)),
            '   {}'.format(group_name),
            '',
        ]

        for idx, line in enumerate(new_content):
            self.content.data.insert(idx, line)
            self.content.items.insert(idx, (None, idx))

        node = nodes.container()
        self.state.nested_parse(self.content, self.content_offset, node)
        return node.children
826605
def _tab(element):
    

    elements = {
        'x': 'tab5.2a.txt',
        'y': 'tab5.2b.txt',
        's': 'tab5.2d.txt'
    }

    if element.lower() not in elements.keys():
        raise ValueError('Unknown element \'%s\'' % element)

    filepath = Path(__file__).parent / "data" / elements[element.lower()]

    total = []
    with filepath.open() as fhd:

        for line in fhd.read().splitlines():

            line = line.strip()

            if line.startswith("#") or not line.strip():
                continue

            if line.startswith('j = '):
                result = []
                total.append(result)
                continue

            # The first field is only an index
            fields = line.split()[1:]
            fields[:2] = [float(x) for x in fields[:2]]
            fields[2:] = [int(x) for x in fields[2:]]
            result.append(fields)

    return total
1317478
function parse( doxComment, options ) {
   if( !( 'ctx' in doxComment ) ) {
      doxComment.ctx = false;
   }

   const parsed = {
      // An explicitly given name is used in favor of a derived one.
      name: ( tagsByType( doxComment.tags, 'name', 'directive', 'injection', 'module' )[ 0 ] || {} ).string ||
         doxComment.ctx.name ||
         '- unknown -',
      description: description( doxComment ),
      dox: doxComment
   };

   const optional = [];
   parsed.params = tagsByType( doxComment.tags, 'param' )
      .map( tag => {
         const cleanName = tag.name.replace( /^\[?([^\]]*)]?$/g, '$1' );
         const parents = cleanName.split( '.' ).slice( 0, -1 );
         if( tag.optional ) {
            optional.push( cleanName );
         }
         else if( parents.some( p => optional.indexOf( p ) !== -1 ) ) {
            // a property of an optional object parameter is optional too
            optional.push( cleanName );
            tag.optional = true;
         }

         return {
            name: cleanName,
            types: tag.types.length === 0 ? [ '*' ] : tag.types,
            description: convertLineBreaks( description( tag ) ),
            dox: tag
         };
      } );

   parsed.paramsForArgsList = parsed.params
      // filter out object parameter properties for argument list
      .filter( param => param.name.indexOf( '.' ) === -1 )
      .map( param => param.name );

   parsed.returns = tagsByType( doxComment.tags, 'return', 'returns' )
      .map( tag =>
         ({
            name: tag.name,
            types: tag.types.length === 0 ? [ '*' ] : tag.types,
            description: convertLineBreaks( description( tag ) ),
            dox: tag
         })
      )[ 0 ] || null;

   if( options.verbose ) {
      /* eslint-disable no-console */
      console.log( JSON.stringify( parsed, null, 3 ) );
      /* eslint-enable no-console */
   }

   return parsed;
}
15333
def read_directive(allowed)
      tk = get_tk
      puts "directive: #{tk.inspect}" if $DEBUG
      result = nil
      if tk.kind_of?(TkCOMMENT) 
        if tk.text =~ /\s*:?(\w+):\s*(.*)/
          directive = $1.downcase
          if allowed.include?(directive)
            result = [directive, $2]
          end
        end
      else
        unget_tk(tk)
      end
      result
    end
421933
function parseOptions(type, options) {
    const ret = {
        indentChar: " ",
        indentSize: 2,
        attribute: 1,
        closeBracket: 0,
    }

    if (Number.isSafeInteger(type)) {
        ret.indentSize = type
    } else if (type === "tab") {
        ret.indentChar = "\t"
        ret.indentSize = 1
    }
    if (Number.isSafeInteger(options.attribute)) {
        ret.attribute = options.attribute
    }
    if (Number.isSafeInteger(options.closeBracket)) {
        ret.closeBracket = options.closeBracket
    }

    return ret
}
1237526
def tag_is_directive?(tag_name)
      list = %w(attribute endgroup group macro method scope visibility)
      list.include?(tag_name)
    end
326393
def parse(directive):
    
    if not directive:
        # Handle null case
        return None

    if isinstance(directive, (list, tuple)):
        results = []
        for d in directive:
            results.extend(parse(d))
        return results

    if isinstance(directive, (dict, client.Placement)):
        # We've been handed something that we can simply hand back to
        # the api. (Forwards compatibility)
        return [directive]

    # Juju 2.0 can't handle lxc containers.
    directive = directive.replace('lxc', 'lxd')

    if ":" in directive:
        # Planner has given us a scope and directive in string form
        scope, directive = directive.split(":")
        return [client.Placement(scope=scope, directive=directive)]

    if directive.isdigit():
        # Planner has given us a machine id (we rely on juju core to
        # verify its validity.)
        return [client.Placement(scope=MACHINE_SCOPE, directive=directive)]

    if "/" in directive:
        # e.g. "0/lxd/0"
        # https://github.com/juju/juju/blob/master/instance/placement_test.go#L29
        return [
            client.Placement(scope=MACHINE_SCOPE, directive=directive),
        ]

    # Planner has probably given us a container type. Leave it up to
    # juju core to verify that it is valid.
    return [client.Placement(scope=directive)]
687630
function tabBrowser_getTab(index) {
    if (index === undefined)
      index = this.selectedIndex;

    return this.getElement({type: "tabs_tab", subtype: "index", value: index});
  }
1046860
def parse(self, elt, ps):
        '''
        '''
        self.checkname(elt, ps)
        if len(_children(elt)) == 0:
            href = _find_href(elt)
            if not href:
                if self.nilled(elt, ps) is False:
                    return []
                if self.nillable is True: 
                    return Nilled
                raise EvaluateException('Required string missing',
                        ps.Backtrace(elt))
            if href[0] != '#':
                return ps.ResolveHREF(href, self)
            elt = ps.FindLocalHREF(href, elt)
            self.checktype(elt, ps)

        if self.nilled(elt, ps): return Nilled
        if len(_children(elt)) == 0: return []

        v = self.simple_value(elt, ps)
        return self.text_to_data(v, elt, ps)
973952
function Parser(options) {
  this.options = merge({}, {
    headers: {
      included: false,
      downcase: true,
      upcase: true
    },
    delimiter: 'tab',
    decimalSign: 'comma'
  }, options);
}
1223950
def parse_directive_location(lexer: Lexer) -> NameNode:
    """"""
    start = lexer.token
    name = parse_name(lexer)
    if name.value in .__members__:
        return name
    raise unexpected(lexer, start)
232316
function parseOptions(obj) {
            var ctr = 0,
                tab = getTabs(1, true);
            for(var prop in obj) {
                if(obj.hasOwnProperty(prop)){
                    if(_.isPlainObject(obj[prop])){
                        if(!_.isEmpty(obj[prop])){
                            var child = recurseChildOptions(obj[prop]);
                            if(child && child.length)
                                build.options.push(tab + prop + ': { \n' + child + ' \n' + tab + '}');
                        }
                    } else {
                        if(_.isArray(obj[prop])){
                            build.options.push(tab + prop + ': ' + arrayToString(obj[prop]));
                        } else {
                            var val = obj[prop];
                            if(_.isString(val))
                                val = qwrap(val);
                            else
                                val = val.toString();
                            build.options.push(tab + prop + ': ' + val);
                        }
                    }
                }
                ctr +=1;
            }

        }
805233
function( tabConfig ) {
			if ( !tabConfig )
				tabConfig = defaultTabConfig;

			var allowedAttrs = [];
			if ( tabConfig.id )
				allowedAttrs.push( 'id' );
			if ( tabConfig.dir )
				allowedAttrs.push( 'dir' );

			var allowed = '';

			if ( allowedAttrs.length )
				allowed += '[' + allowedAttrs.join( ',' ) +  ']';

			if ( tabConfig.classes )
				allowed += '(*)';
			if ( tabConfig.styles )
				allowed += '{*}';

			return allowed;
		}
150446
def translate_tab(data):
    
    tab_str = ""
    sections = data.get("Sections", [])
    for section in sections:
            print("  Translating " + section["Type"])
            tab_str += translate_map[section["Type"]](section)
    return tab_str
290419
private Text parseText(Node el, Map<String, Scope> scopes) {
        Text text;
        if (nodeAttribute(el, TAG_VAR_ATTR_INHERIT, DEFAULT_INHERIT_VALUE)) {
            text = new Text(
                    nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
                    null,
                    nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
            );
        } else {
            String scopeName = nodeAttribute(el, TAG_SCOPE, Scope.ROOT);
            Scope scope = scopes.get(scopeName);
            if (scope == null) {
                throw new TextProcessorFactoryException(
                        MessageFormat.format("Scope \"{0}\" not found.", scopeName)
                );
            }

            text = new Text(
                    nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
                    scope,
                    nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
            );
        }
        return text;
    }
779955
def _parse_directive(self, directive):
        
        words = directive.split()
        if len(words) == 1 and words[0] not in ('include', 'exclude',
                                                'global-include',
                                                'global-exclude',
                                                'recursive-include',
                                                'recursive-exclude',
                                                'graft', 'prune'):
            # no action given, let's use the default 'include'
            words.insert(0, 'include')

        action = words[0]
        patterns = thedir = dir_pattern = None

        if action in ('include', 'exclude',
                      'global-include', 'global-exclude'):
            if len(words) < 2:
                raise DistlibException(
                    '%r expects <pattern1> <pattern2> ...' % action)

            patterns = [convert_path(word) for word in words[1:]]

        elif action in ('recursive-include', 'recursive-exclude'):
            if len(words) < 3:
                raise DistlibException(
                    '%r expects <dir> <pattern1> <pattern2> ...' % action)

            thedir = convert_path(words[1])
            patterns = [convert_path(word) for word in words[2:]]

        elif action in ('graft', 'prune'):
            if len(words) != 2:
                raise DistlibException(
                    '%r expects a single <dir_pattern>' % action)

            dir_pattern = convert_path(words[1])

        else:
            raise DistlibException('unknown action %r' % action)

        return action, patterns, thedir, dir_pattern
1047258
def _render_tab(lst):
    '''
    
    '''
    ret = []
    for pre in lst['pre']:
        ret.append('{0}\n'.format(pre))
    for cron in lst['crons']:
        ret.append('{0} {1} {2} {3}\n'.format(cron['path'],
                                                      cron['mask'],
                                                      cron['cmd'],
                                                      TAG
                                                      )
                   )
    return ret