Grab package verion
543224
def description(self):
        
        for line in self.SLACKBUILDS_TXT.splitlines():
            if line.startswith(self.line_name):
                sbo_name = line[17:].strip()
            if line.startswith(self.line_des):
                if sbo_name == self.name:
                    return line[31:].strip()
1046268
function (params) {
        var self = this;
        this.parseParams(params);
        if (!this.loaded) {
          this.fetchApi(api).success(function (data) {
            packages = data;
            self.loaded = true;
            self.search();
          });
        }
        else {
          this.search();
        }
      }
627478
function getInfo(d) {
  var p = path.join(d, 'package.json')
  return exists(p) ? require(p) : false
}
860904
def _collect_from_package(self, module,
                              type_checker: Optional[FunctionType] = None,
                              ) -> Dict[str, Any]:
        
        type_checker = type_checker or self.type_check
        members = dict(self._get_members(module, type_checker))

        if pkgutil.get_loader(module).is_package(module.__name__):
            for loader, name, is_pkg in pkgutil.walk_packages(module.__path__):
                child_module_name = f'{module.__package__}.{name}'
                child_module = importlib.import_module(child_module_name)
                for key, obj in self._get_members(child_module, type_checker):
                    if key not in members:
                        members[key] = obj

        return members
1107806
def capture(package, prefix, modules=[], level=logging.DEBUG):
    
    handler = LogFileHandler(package, prefix)
    formatter = logging.Formatter(FORMAT)
    handler.setFormatter(formatter)
    modules = set(modules + ['loadkit'])

    for logger in modules:
        if not hasattr(logger, 'addHandler'):
            logger = logging.getLogger(logger)
        logger.setLevel(level=level)
        logger.addHandler(handler)

    return handler
714293
def get_package_data(name, extlist):
    """"""
    flist = []
    # Workaround to replace os.path.relpath (not available until Python 2.6):
    offset = len(name)+len(os.pathsep)
    for dirpath, _dirnames, filenames in os.walk(name):
        for fname in filenames:
            if not fname.startswith('.') and osp.splitext(fname)[1] in extlist:
                flist.append(osp.join(dirpath, fname)[offset:])
    return flist
824555
def packb(obj, **kwargs):
    """"""
    kwargs.setdefault('use_bin_type', True)
    return msgpack.packb(obj, **kwargs)
517296
function getPackageReportData(package, versionRangeOrCallback, callback) {
	var versionRange = versionRangeOrCallback

	if (arguments.length === 2) {
		var split = package.split('@')
		
		if (split.length !== 2) {
			throw new Error('invalid package: ' + package)
		}

		callback = versionRangeOrCallback
		package = split[0]
		versionRange = split[1]
	}

	if (typeof callback !== 'function') {
		throw new Error('missing callback argument')
	}
	
	versionRange = semver.validRange(versionRange)

	if (!versionRange) {
		var message = util.format('skipping %s (invalid semversion)', package)
		
		return callback(null, { name: package, comment: message })
	}

	getPackageJson(package, function(err, json) {
		if (err) return callback(err)

		// dont think it is possible but just to make sure.
		if (!json.versions) {
			return callback(new Error('no versions in registry for package ' + package))
		}

		// find the right version for this package
		var versions = _.keys(json.versions)

		var version = semver.maxSatisfying(versions, versionRange)

		if (!version) {
			return callback(new Error('cannot find a version that satisfies range ' + versionRange + ' in the registry'))
		}

		getPackageJson(package, version, function(err, json) {
			if (err) return callback(err)

			/*
				finally, callback with all the data
			*/
			callback(null, { 
				name: package,
				licenseType: extractLicense(json),
				link: extractLink(json),
				comment: version.toString()
			})
		})
	})
}
48304
function install(thorin, item, done) {
  let calls = [];
  let config = item.opt.releaser,
    url = `${API}/services/download?token=` + config.token,
    zipPath,
    folderPath = path.normalize(`${thorin.root}/node_modules/thorin-module-${item.name}`);
  let filePath = folderPath + '.zip',
    result = {
      path: folderPath
    };

  /* Step one: download from Releaser if we have a releaser config */
  calls.push((fn) => {
    console.log(`Thorin: downloading module ${item.name} to ${folderPath}`);
    download(url, {
      path: folderPath
    }, fn);
  });

  /* Next, we have to unzip the file */
  calls.push((fn) => {
    fse.ensureDir(folderPath, fn);
  });

  /* Next, we have to install archiver */
  calls.push((fn) => {
    console.log(`Thorin: installing ${DEPS.join(', ')}`);
    let cmd = `npm i -p ${DEPS.join(' ')}`,
      opt = {
        cwd: thorin.root
      };
    exec(cmd, opt, (err, res) => {
      if (err) return fn(err);
      fn();
    });
  });

  /* Next, unzip it */
  calls.push(async (fn) => {
    console.log(`Thorin: unzipping to: ${folderPath}`);
    const unzip2 = require(path.normalize(thorin.root + `/node_modules/unzip2`));
    unzip(unzip2, filePath, folderPath, fn);
  });

  /* Finally, install its dependencies */
  calls.push((fn) => {
    console.log(`Thorin: installing module dependencies`);
    let cmd = `npm i -p`;
    exec(cmd, {
      cwd: folderPath
    }, fn);
  });

  /* Cleanup */
  calls.push((fn) => {
    fs.unlink(filePath, (e) => {
      if (e) {
        console.log(`Thorin: failed to remove module ${filePath}`);
        console.log(e);
      }
      fn();
    });
  });

  async.series(calls, (e) => {
    if (e) return done(e);
    done(null, result);
  });
}
113432
function get( opts, clbk ) {
	var scount;
	var fcount;
	var count;
	var pkgs;
	var eFLG;
	var out;
	var idx;
	var len;
	var i;

	// Output data store:
	out = {};
	out.meta = {};
	out.data = {};
	out.failures = {};

	// Number of completed requests:
	count = 0;
	scount = 0; // success
	fcount = 0; // failures

	// Request id:
	idx = 0;

	pkgs = opts.packages;
	len = pkgs.length;

	debug( 'Number of packages: %d.', len );
	out.meta.total = len;

	debug( 'Beginning queries...' );
	for ( i = 0; i < NUM_CONCURRENT_REQUESTS; i++ ) {
		next();
	}
	/**
	* FUNCTION: next()
	*	Requests package data for the next package in the queue. Once requests for all desired packages have completed, invokes the provided callback.
	*
	* @private
	* @returns {Void}
	*/
	function next() {
		if ( count === len ) {
			debug( 'Finished all queries.' );
			out.meta.success = scount;
			out.meta.failure = fcount;
			return clbk( null, out );
		}
		if ( idx < len ) {
			debug( 'Querying for package: `%s` (%d)...', pkgs[idx], idx );
			request( pkgs[idx], opts, onResponse( pkgs[idx], idx ) );
			idx += 1;
		}
	} // end FUNCTION next()

	/**
	* FUNCTION: onResponse( pkg, idx )
	*	Returns a response callback.
	*
	* @private
	* @param {String} pkg - package name
	* @param {Number} idx - request index
	* @returns {Function} response callback
	*/
	function onResponse( pkg, idx ) {
		/**
		* FUNCTION: onResponse( error, data )
		*	Callback invoked upon receiving a request response.
		*
		* @private
		* @param {Error|Null} error - error object
		* @param {Object} data - response data
		* @returns {Void}
		*/
		return function onResponse( error, data ) {
			if ( eFLG ) {
				return;
			}
			debug( 'Response received for package: `%s` (%d).', pkg, idx );
			if ( error ) {
				if ( error instanceof Error ) {
					eFLG = true;
					return clbk( error );
				}
				debug( 'Failed to resolve package `%s` (%d): %s', pkg, idx, error.message );
				out.failures[ pkg ] = error.message;
				fcount += 1;
			} else {
				debug( 'Successfully resolved package `%s` (%d).', pkg, idx );
				out.data[ pkg ] = data;
				scount += 1;
			}
			count += 1;
			debug( 'Request %d of %d complete.', count, len );
			next();
		}; // end FUNCTION onResponse()
	} // end FUNCTION onResponse()
}
1028123
function tree (dir, opts, cb) {
  var i = 0
  findPackage(dir, function (err, pkg) {
    pull(
      pull.depthFirst(pkg, function (pkg) {
        pkg.tree = {}
        return pull(
          pfs.readdir(path.resolve(pkg.path, 'node_modules')),
          paramap(maybe(readPackage)),
          pull.filter(function (_pkg) {
            if(!_pkg) return
            _pkg.parent = pkg
            
            pkg.tree[_pkg.name] = _pkg
            return pkg
          })
        )
      }),
      opts.post ? paramap(function (data, cb) {
        //run a post install-style hook.
        opts.post(data, cb)
      }) : pull.through(),
      pull.drain(null, function (err) {
        cb(err === true ? null : err, clean(pkg))
      })
    )
  })
}
293554
def install_importer():
    
    logging.debug('install_importer')
    if not in_venv():
        logging.debug('No virtualenv active py:[%s]', sys.executable)
        return False

    if disable_vext:
        logging.debug('Vext disabled by environment variable')
        return False

    if GatekeeperFinder.PATH_TRIGGER not in sys.path:
        try:
            load_specs()
            sys.path.append(GatekeeperFinder.PATH_TRIGGER)
            sys.path_hooks.append(GatekeeperFinder)
        except Exception as e:
            """
            Dont kill other programmes because of a vext error
            """
            logger.info(str(e))
            if logger.getEffectiveLevel() == logging.DEBUG:
                raise

        logging.debug("importer installed")
        return True
267398
function(req, res) {
            var packages = {};
            var appJSON = require('../../package.json');
            packages[appJSON.name] = appJSON;
            packages['onm'] = require('../onm/package.json');
            res.send(packages);
        }
590205
def remote():
    """"""
    logger.info("Fetching latest data from PyPI.")
    results = defaultdict(list)
    packages = PackageVersion.objects.exclude(is_editable=True)
    for pv in packages:
        pv.update_from_pypi()
        results[pv.diff_status].append(pv)
        logger.debug("Updated package from PyPI: %r", pv)
    results['refreshed_at'] = tz_now()
    return results
295942
def pull(self):
        """"""

        # For each packet in the pcap process the contents
        for item in self.input_stream:

            # Print out the timestamp in UTC
            print('Timestamp: %s' % item['timestamp'])

            # Unpack the Ethernet frame (mac src/dst, ethertype)
            print('Ethernet Frame: %s --> %s  (type: %d)' % \
                  (net_utils.mac_to_str(item['eth']['src']), net_utils.mac_to_str(item['eth']['dst']), item['eth']['type']))

            # Print out the Packet info
            packet_type = item['packet']['type']
            print('Packet: %s ' % packet_type, end='')
            packet = item['packet']
            if packet_type in ['IP', 'IP6']:
                print('%s --> %s (len:%d ttl:%d)' % (net_utils.inet_to_str(packet['src']), net_utils.inet_to_str(packet['dst']),
                                                     packet['len'], packet['ttl']), end='')
                if packet_type == 'IP':
                    print('-- Frag(df:%d mf:%d offset:%d)' % (packet['df'], packet['mf'], packet['offset']))
                else:
                    print()
            else:
                print(str(packet))

            # Print out transport and application layers
            if item['transport']:
                transport_info = item['transport']
                print('Transport: %s ' % transport_info['type'], end='')
                for key, value in compat.iteritems(transport_info):
                    if key != 'data':
                        print(key+':'+repr(value), end=' ')

                # Give summary info about data
                data = transport_info['data']
                print('\nData: %d bytes' % len(data), end='')
                if data:
                    print('(%s...)' % repr(data)[:30])
                else:
                    print()

            # Application data
            if item['application']:
                print('Application: %s' % item['application']['type'], end='')
                print(str(item['application']))

            # Is there domain info?
            if 'src_domain' in packet:
                print('Domains: %s --> %s' % (packet['src_domain'], packet['dst_domain']))

            # Tags
            if 'tags' in item:
                print(list(item['tags']))
            print()
731308
def retrieve():
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x1c)  # 00011100
    packet = a / b
    return packet
1012278
function(callback) {
    var packageToVersions = this.packageToVersions;
    var count = Package.versionCount(packageToVersions);
    if (count === 0) {
      return callback && callback();
    }

    var packages = Object.keys(packageToVersions);
    async.parallel(
      packages
        .map(function(package) {
          var versions = Object.keys(packageToVersions[package]);
          return versions.map(function(version) {
            return this.downloadPackageVersion.bind(this, package, version);
          }.bind(this));
        }.bind(this))
        .reduce(function(prev, curr) {
          return prev.concat(curr);
        }),
      function(err) {
        return callback && callback(err);
      }
    );
  }