/* Expands short spec definitions into full definitions
173227
function normalize (specs) {
  const arrayedSpecs = Array.isArray(specs) ? specs : [specs]
  const objectifiedSpecs = arrayedSpecs.map(normalizeSpec)
  return objectifiedSpecs
}
587543
function lookupSpecMatch(lookup, spec) {
  // Direct match
  if (lookup[spec]) {
    return lookup[spec];
  }

  // Close match
  var shortSpec = spec.replace(/@\D/g,'@');
  if (lookup[shortSpec]) {
    return lookup[shortSpec];
  }

  // Check for Semver valid match
  var lastIndex = spec.lastIndexOf('@');
  var myName = spec.substring(0, lastIndex);
  var myVersion = spec.substring(lastIndex + 1);
  for(var k in lookup) {
    lastIndex = k.lastIndexOf('@');
    var yourName = k.substring(0, lastIndex);
    var yourVersion = k.substring(lastIndex + 1);
    if (myName == yourName && semver.valid(yourVersion) && semver.satisfies(yourVersion, myVersion)) {
      return lookup[k];
    }
  }
  return undefined;
}
1358763
function processDefinition(definition) {
    var fields = [];
    var types = {};
    var key;
    var fieldDefinition;
    var type;

    for (key in definition) {
        if (definition.hasOwnProperty(key)) {
            fields.push(key);

            fieldDefinition = definition[key];
            type = determineType(fieldDefinition);

            // Normalize the type definition
            if (value(fieldDefinition).getConstructor() === Object) {
                definition[key].type = type;
            } else {
                definition[key] = {
                    type: type
                };
            }

            if (value(fieldDefinition).getConstructor() === Object) {
                definition[key].writable = fieldDefinition.hasOwnProperty("writable") ? fieldDefinition.writable : true;
            } else {
                definition[key].writable = true;
            }

            if (value(fieldDefinition).getConstructor() === Object) {
                definition[key].readable = fieldDefinition.hasOwnProperty("readable") ? fieldDefinition.readable : true;
            } else {
                definition[key].readable = true;
            }

            types[key] = type;
        }
    }

    return {
        fields: fields,
        types: types
    };
}
931289
function expandSchemaDescriptor(descriptor) {
  for (const field of (descriptor.fields || [])) {
    expandFieldDescriptor(field)
  }
  if (!descriptor.missingValues) descriptor.missingValues = config.DEFAULT_MISSING_VALUES
  return descriptor
}
1274594
function specs() {
    var routes = {};

    // Reducing the app's recursive stack
    function reduceStack(path, items, item) {
      var nextPath;

      if (item.handle && item.handle.stack) {
        nextPath = join(path, (item.path || helpers.unescapeRegex(item.regexp) || ''));
        return items.concat(item.handle.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      if (item.route) {
        nextPath = join(path, (item.route.path || ''));
        return items.concat(item.route.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      return items.concat({
        handle: item.handle,
        path: path
      });
    }

    // Filtering the actions coming from dolman
    app._router.stack
      .reduce(reduceStack.bind(null, ''), [])
      .map(function(item) {
        return {
          route: routesMap.get(item.handle),
          path: item.path
        };
      })
      .filter(function(item) {
        return item.route && item.route.name;
      })
      .forEach(function(item) {
        var route = item.route,
            method = [].concat(route.method || route.methods)[0];

        var routeData = {
          path: item.path,
          name: route.name,
          method: !method || method === 'ALL' ? 'GET' : method
        };

        ['description'].forEach(function(k) {
          if (route[k])
            routeData[k] = route[k];
        });

        routes[route.name] = routeData;
      });

    return {
      formats: ['json'],
      methods: routes
    };
  }
704665
function expandXBounds(bounds, value) {
  if (bounds[MIN_X] > value) bounds[MIN_X] = value;else if (bounds[MAX_X] < value) bounds[MAX_X] = value;
}
288563
function parseExtensions(collection, extensions) {
  extensions.forEach(extNode => {
    const ext = new AdExtension();
    const extNodeAttrs = extNode.attributes;
    const childNodes = extNode.childNodes;

    if (extNode.attributes) {
      for (const extNodeAttrKey in extNodeAttrs) {
        const extNodeAttr = extNodeAttrs[extNodeAttrKey];

        if (extNodeAttr.nodeName && extNodeAttr.nodeValue) {
          ext.attributes[extNodeAttr.nodeName] = extNodeAttr.nodeValue;
        }
      }
    }

    for (const childNodeKey in childNodes) {
      const childNode = childNodes[childNodeKey];
      const txt = parserUtils.parseNodeText(childNode);

      // ignore comments / empty value
      if (childNode.nodeName !== '#comment' && txt !== '') {
        const extChild = new AdExtensionChild();
        extChild.name = childNode.nodeName;
        extChild.value = txt;

        if (childNode.attributes) {
          const childNodeAttributes = childNode.attributes;

          for (const extChildNodeAttrKey in childNodeAttributes) {
            const extChildNodeAttr = childNodeAttributes[extChildNodeAttrKey];

            extChild.attributes[extChildNodeAttr.nodeName] =
              extChildNodeAttr.nodeValue;
          }
        }

        ext.children.push(extChild);
      }
    }

    collection.push(ext);
  });
}
467929
function extendFormatExtensions (extensionName, extensionValue) {
        if (typeof extensionName !== 'string' || !(extensionValue instanceof RegExp)) {
            throw new Error('extensionName or extensionValue undefined or not correct type');
        }

        if (revalidator.validate.formats.hasOwnProperty(extensionName) ||
            revalidator.validate.formats.hasOwnProperty(extensionName)) {
            var msg = 'extensionName: ' + extensionName + ' already exists in formatExtensions.';
            throw  new Error(msg);
        }

        revalidator.validate.formatExtensions[extensionName] = extensionValue;
    }
1080646
function createChecksString(fieldDefinition, fieldName) {
  let checks = [];

  const fieldCase = propertyHelper.getProperty(fieldDefinition, 'fieldCase');
  const minLength = propertyHelper.getProperty(fieldDefinition, 'minLength');
  const maxLength = propertyHelper.getProperty(fieldDefinition, 'maxLength');
  const regExStr = propertyHelper.getProperty(fieldDefinition, 'regEx');
  let regEx;
  if (regExStr) {
    regEx = new RegExp(regExStr);
  }


  const minLengthSeverity = propertyHelper.getSeverity(fieldDefinition, 'minLength');
  const maxLengthSeverity = propertyHelper.getSeverity(fieldDefinition, 'maxLength');
  const regExSeverity = propertyHelper.getSeverity(fieldDefinition, 'regEx');

  // -----------------------------------------------------------------------
  // Create FIELD CASE Check
  // -----------------------------------------------------------------------
  /*
   * The first check is only for updating the string to lower or to upper case.
   * It will not reurn any error
   */
  if (fieldCase !== undefined) {

    /**
     * Changes the case of a string to the given value (upper, lower)
     */
    checks.push(function (content) {
      const valueToCheck = content[fieldName];
      // If the value is defined, we need to check it
      if (valueToCheck !== undefined && valueToCheck !== null) {
        if (Array.isArray(valueToCheck)) {
          valueToCheck.forEach(function (item, idx, arr) {
            if (item === undefined || item === null) {

              if (fieldCase === 'lower') {
                arr[idx] = item.toLowerCase();
              } else if (fieldCase === 'upper') {
                arr[idx] = item.toUpperCase();
              }
            }
          });
        } else {
          if (fieldCase === 'lower') {
            content[fieldName] = valueToCheck.toLowerCase();
          } else if (fieldCase === 'upper') {
            content[fieldName] = valueToCheck.toUpperCase();
          }
        }
      }
    });
  }


  // -----------------------------------------------------------------------
  // Create MIN LENGTH Check
  // -----------------------------------------------------------------------
  if (minLength !== undefined) {
    /**
     * Checks that the given string has a minimum length
     * @param content the content hash to be validated.
     * @return error an error object if the given value is too short
     */
    checks.push(function (content) {
      const valueToCheck = content[fieldName];
      // If the value is defined, we need to check it
      if (valueToCheck !== undefined && valueToCheck !== null) {

        let errors = [];

        if (Array.isArray(valueToCheck)) {
          valueToCheck.forEach(function (item, idx, arr) {
            if (item.length < minLength) {
              errors.push({
                errorCode: 'STRING_MIN_LENGTH',
                severity: minLengthSeverity,
                fieldName: fieldName,
                value: item,
                message: minLength
              });
            }
          });
        } else {
          if (valueToCheck.length < minLength) {
            errors.push({
              errorCode: 'STRING_MIN_LENGTH',
              severity: minLengthSeverity,
              fieldName: fieldName,
              value: valueToCheck,
              message: minLength
            });
          }
        }

        if (errors.length == 1) {
          return errors[0];
        } else if (errors.length > 1) {
          return errors;
        }
      }
    });
  }

  // -----------------------------------------------------------------------
  // Create MAX LENGTH Check
  // -----------------------------------------------------------------------
  if (maxLength !== undefined) {
    /**
     * Checks that the given string does not exeed the maximum length
     * @param content the content hash to be validated.
     * @return error an error object if the given value is too long
     */
    checks.push(function (content) {
      const valueToCheck = content[fieldName];
      // If the value is defined, we need to check it
      if (valueToCheck !== undefined && valueToCheck !== null) {

        let errors = [];

        if (Array.isArray(valueToCheck)) {
          valueToCheck.forEach(function (item, idx, arr) {
            if (item.length > maxLength) {
              arr[idx] = item.substring(0, maxLength);

              errors.push({
                errorCode: 'STRING_MAX_LENGTH',
                severity: maxLengthSeverity,
                fieldName: fieldName,
                value: item,
                message: maxLength
              });
            }
          });

          content[fieldName] = valueToCheck;
        } else {
          if (valueToCheck.length > maxLength) {
            content[fieldName] = valueToCheck.substring(0, maxLength);

            errors.push({
              errorCode: 'STRING_MAX_LENGTH',
              severity: maxLengthSeverity,
              fieldName: fieldName,
              value: valueToCheck,
              message: maxLength
            });
          }
        }

        if (errors.length == 1) {
          return errors[0];
        } else if (errors.length > 1) {
          return errors;
        }
      }
    });
  }

  // -----------------------------------------------------------------------
  // Create REG EX Check
  // -----------------------------------------------------------------------
  if (regEx !== undefined) {
    /**
     * Checks that the given string has a minimum length
     * @param content the content hash to be validated.
     * @return error an error object if the given value is not a valid date
     */
    checks.push(function (content) {
      const valueToCheck = content[fieldName];
      // If the value is defined, we need to check it
      if (valueToCheck !== undefined && valueToCheck !== null) {

        let errors = [];

        if (Array.isArray(valueToCheck)) {
          valueToCheck.forEach(function (item, idx, arr) {
            if (!regEx.test(item)) {
              arr[idx] = item.substring(0, maxLength);

              errors.push({
                errorCode: 'STRING_REG_EX',
                severity: regExSeverity,
                fieldName: fieldName,
                value: item,
                message: regExStr
              });
            }
          });
        } else {
          if (!regEx.test(valueToCheck)) {
            errors.push({
              errorCode: 'STRING_REG_EX',
              severity: regExSeverity,
              fieldName: fieldName,
              value: valueToCheck,
              message: regExStr
            });
          }
        }

        if (errors.length == 1) {
          return errors[0];
        } else if (errors.length > 1) {
          return errors;
        }
      }
    });
  }
  return checks;
}
1039667
def flatten_spec(spec, prefix,joiner=" :: "):
  """"""

  if any(filter(operator.methodcaller("startswith","Test"),spec.keys())):
    flat_spec = {}
    for (k,v) in spec.items():
      flat_spec.update(flatten_spec(v,prefix + joiner + k[5:]))
    return flat_spec 
  else:
    return {"Test "+prefix: spec}
1247481
function deeplyExtendPkg(a, b) {
	if(!a.resolutions) {
		a.resolutions = {};
	}
	utils.extend(a.resolutions, b.resolutions || {});

	if(!a.steal) {
		a.steal = {};
	}
	if(!b.steal) {
		b.steal = {};
	}

	utils.extend(a.steal, b.steal, true);
}
203674
function extend(dest, source){
    for (var key in source)
      dest[key] = source[key];

    return dest;
  }
381079
function expandImplicitContent( attribs ) {
    try {
        if ( !attribs ) return;
        if ( typeof attribs.implicit === 'undefined' ) return;
        const implicitContent = attribs.implicit[ 1 ];
        if ( typeof implicitContent === 'undefined' ) return;

        const explicitContent = attribs.standard ? attribs.standard.content : undefined;
        if ( explicitContent ) {
            throw "Can't mix implicit and explicit `content`:\n" +
                "    implicit: " + limitJson( implicitContent ) + "\n" +
                "    explicit: " + limitJson( explicitContent );
        }

        attribs.standard.content = implicitContent;
    } catch ( ex ) {
        throw ex + "\n...in expandImplicitContent: " + limitJson( attribs );
    }
}
792497
def expand_state_definition(source, loc, tokens):
    
    indent = " " * (pp.col(loc, source) - 1)
    statedef = []

    # build list of states
    states = set()
    fromTo = {}
    for tn in tokens.transitions:
        states.add(tn.from_state)
        states.add(tn.to_state)
        fromTo[tn.from_state] = tn.to_state

    # define base class for state classes
    baseStateClass = tokens.name
    statedef.extend([
        "class %s(object):" % baseStateClass,
        "    def __str__(self):",
        "        return self.__class__.__name__",

        "    @classmethod",
        "    def states(cls):",
        "        return list(cls.__subclasses__())",

        "    def next_state(self):",
        "        return self._next_state_class()",
    ])

    # define all state classes
    statedef.extend("class {0}({1}): pass".format(s, baseStateClass) for s in states)

    # define state->state transitions
    statedef.extend("{0}._next_state_class = {1}".format(s, fromTo[s]) for s in states if s in fromTo)

    statedef.extend([
        "class {baseStateClass}Mixin:".format(baseStateClass=baseStateClass),
        "    def __init__(self):",
        "        self._state = None",

        "    def initialize_state(self, init_state):",
        "        self._state = init_state",

        "    @property",
        "    def state(self):",
        "        return self._state",

        "    # get behavior/properties from current state",
        "    def __getattr__(self, attrname):",
        "        attr = getattr(self._state, attrname)",
        "        return attr",

        "    def __str__(self):",
        "       return '{0}: {1}'.format(self.__class__.__name__, self._state)",
        ])

    return indent + ("\n" + indent).join(statedef) + "\n"
1303902
private function expandShorthandDefinitions()
    {
        foreach ($this->mapping as $key => $settings) {
            if (is_string($key) && is_string($settings)) {
                $this->mapping[$key] = [
                    'type' => 'column',
                    'mapping' => [
                        'destination' => $settings
                    ]
                ];
            }
        }
    }
216435
function expand(docset, customTags) {
    docset["comment"] = DocParser.parse(docset["comment"], customTags);
    docset["tagname"] = DocType.detect(docset["comment"], docset["code"]);

    if (docset["tagname"] == "class")
      return DocExpander.expand(docset);
    else
      return docset;
}
878084
function _customDefinitions (type, object) {
  var errors

  if (isFunction(definitions[type])) {
    try {
      errors = definitions[type](object)
    } catch (e) {
      errors = ['Problem with custom definition for '+type+': '+e]
    }
    if (typeof result === 'string') {
      errors = [errors]
    }
    if (Object.prototype.toString.call(errors) === '[object Array]') {
      return errors
    }
  }
  return []
}