Add a ``Detector`` to scrubadub
507210
def add_detector(self, detector_cls):
        """"""
        if not issubclass(detector_cls, detectors.base.Detector):
            raise TypeError((
                '"%(detector_cls)s" is not a subclass of Detector'
            ) % locals())
        # TODO: should add tests to make sure filth_cls is actually a proper
        # filth_cls
        name = detector_cls.filth_cls.type
        if name in self._detectors:
            raise KeyError((
                'can not add Detector "%(name)s"---it already exists. '
                'Try removing it first.'
            ) % locals())
        self._detectors[name] = detector_cls()
1075781
function(src, noEscape) {
    var attrLen, newKey;
    if (helper.isArray(src)) {
      var attrLen = src.length;
      for (var i = 0; i < attrLen; i++) {
        src[i] = helper.pasteurize(src[i], noEscape);
      }
    } else if (this.isString(src)) {
      src = helper.scrub(src, noEscape);
    } else if (helper.isObject(src)) {
      var newSrc = {};
      for (key in src) {
        newKey = helper.scrub(key);
        newSrc[newKey] = helper.pasteurize(src[key], noEscape);
      }
      src = newSrc;
    }

    return src;
  }
1312407
function Detector() {
      var _this;

      var ua = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
      var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
      var cssFlags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
      var cssFlagsPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'djs';

      _classCallCheck(this, Detector);

      _this = _possibleConstructorReturn(this, _getPrototypeOf(Detector).call(this, ua));
      _this._values = values;
      _this._cssFlags = !!cssFlags ? [] : null;
      _this._cssFlagsPrefix = cssFlagsPrefix + (!!cssFlagsPrefix ? '--' : ''); //! Features

      _this.checkFeature(); //! Software


      _this.checkEngine();

      _this.checkBrowser();

      _this.checkOS(); //! Hardware
      // this.checkDevice();


      _this.checkCPU();

      _this.checkGPU();

      _this.checkPlatform();

      _this.setCssFlags(); // remove unnecessary memory usage


      delete _this._booleanFlagsValuePropertyName;
      delete _this._values;
      delete _this._cssFlags;
      delete _this._cssFlagsPrefix;
      delete _this._root;
      delete _this._process;
      delete _this._navigator;
      delete _this._document;
      delete _this._ua;
      console.warn('DetectorJS initialized', _this.toFlags());
      return _this;
    }
1323261
def _GetPurgeMessage(most_recent_step, most_recent_wall_time, event_step,
                     event_wall_time, num_expired_scalars, num_expired_histos,
                     num_expired_comp_histos, num_expired_images,
                     num_expired_audio):
  """"""
  return ('Detected out of order event.step likely caused by '
          'a TensorFlow restart. Purging expired events from Tensorboard'
          ' display between the previous step: {} (timestamp: {}) and '
          'current step: {} (timestamp: {}). Removing {} scalars, {} '
          'histograms, {} compressed histograms, {} images, '
          'and {} audio.').format(most_recent_step, most_recent_wall_time,
                                  event_step, event_wall_time,
                                  num_expired_scalars, num_expired_histos,
                                  num_expired_comp_histos, num_expired_images,
                                  num_expired_audio)
614625
function() {
    var parser = new(window.UAParser || exports.UAParser);
    browserData = parser.getResult();
    fontDetective = new Detector();
    return this;
  }
866191
function performCleanup(requester, filesToCache, notifyBack) {
        var currentRequester = requester || "";
        function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
            files.forEach(function (file) {
                var fileExt = path.extname(path.basename(file));
                if (filesToCacheArr.indexOf(fileExt) < 0) {
                    var fileFullPath = updateDir + '/' + file;
                    try {
                        fs.removeSync(fileFullPath);
                    } catch (e) {
                        console.log("AutoUpdate : Exception occured in removing ", fileFullPath, e);
                    }
                }
            });
            if (notifyBackToBrackets) {
                postMessageToBrackets(MessageIds.NOTIFY_SAFE_TO_DOWNLOAD, currentRequester);
            }
        }

        fs.stat(updateDir)
            .then(function (stats) {
                if (stats) {
                    if (filesToCache) {
                        fs.readdir(updateDir)
                            .then(function (files) {
                                filterFilesAndNotify(files, filesToCache, notifyBack);
                            })
                            .catch(function (err) {
                                console.log("AutoUpdate : Error in Reading Update Dir for Cleanup : " + err.toString());
                                postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
                                                      currentRequester, nodeErrorMessages.UPDATEDIR_READ_FAILED);
                            });
                    } else {
                        fs.remove(updateDir)
                            .then(function () {
                                console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
                            })
                            .catch(function (err) {
                                console.log("AutoUpdate : Error in Cleaning Update Dir : " + err.toString());
                                postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
                                                      currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
                            });
                    }
                }
            })
            .catch(function (err) {
                console.log("AutoUpdate : Error in Reading Update Dir stats for Cleanup : " + err.toString());
                postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
                                      currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
            });
    }
1221080
def generate_strip_subparser(subparsers):
    """"""
    parser = subparsers.add_parser(
        'strip', description=constants.STRIP_DESCRIPTION,
        epilog=constants.STRIP_EPILOG, formatter_class=ParagraphFormatter,
        help=constants.STRIP_HELP)
    parser.set_defaults(func=strip_files)
    utils.add_common_arguments(parser)
    parser.add_argument('input', help=constants.STRIP_INPUT_HELP,
                        metavar='INPUT')
    parser.add_argument('output', help=constants.STRIP_OUTPUT_HELP,
                        metavar='OUTPUT')
762898
def clean_add_strdec(*args, prec=28):
    """"""

    # load modules
    import pandas as pd
    import numpy as np
    import re
    from decimal import Decimal, getcontext
    getcontext().prec = prec

    # initialize result as 0.0
    def proc_elem(*args):
        t = Decimal('0.0')
        for a in args:
            if isinstance(a, str):
                a = re.sub('[^0-9\.\-]+', '', a)

            if a and pd.notnull(a):
                t += Decimal(a)

        return str(t)

    def proc_list(arr):
        return [proc_elem(*row) for row in arr]

    def proc_ndarray(arr):
        return np.array(proc_list(arr))

    # transform depending on provided datatypes
    if isinstance(args[0], (list, tuple)):
        return proc_list(args[0])
    elif isinstance(args[0], np.ndarray):
        return proc_ndarray(args[0])
    elif isinstance(args[0], pd.DataFrame):
        return pd.DataFrame(proc_ndarray(args[0].values),
                            index=args[0].index)
    else:
        return proc_elem(*args)
491675
def register_detector(self, detector_class):
        
        self._check_common_things('detector', detector_class, AbstractDetector, self._detectors)

        instance = detector_class(self, logger_detector)
        self._detectors.append(instance)
303165
def __undo_filter_sub(self, scanline):
        """"""
        ai = 0
        # Loops starts at index fu.
        for i in range(self.fu, len(scanline)):
            x = scanline[i]
            a = scanline[ai]  # result
            scanline[i] = (x + a) & 0xff  # result
            ai += 1
411957
def _scrub_generated_timestamps(self, target_workdir):
    """"""
    for root, _, filenames in safe_walk(target_workdir):
      for filename in filenames:
        source = os.path.join(root, filename)

        with open(source, 'r') as f:
          lines = f.readlines()
        if len(lines) < 1:
          return
        with open(source, 'w') as f:
          if not self._COMMENT_WITH_TIMESTAMP_RE.match(lines[0]):
            f.write(lines[0])
          for line in lines[1:]:
            f.write(line)
180581
def setup_signals(self, ):
        
        self.showfilter_tb.toggled.connect(self.switch_showfilter_icon)
        self.addnew_tb.clicked.connect(self.open_addnew_win)
        self.search_le.editingFinished.connect(self.update_filter)
        for cb in (self.loaded_checkb, self.unloaded_checkb, self.imported_checkb, self.empty_checkb,
                   self.newest_checkb, self.old_checkb, self.alien_checkb):
            cb.toggled.connect(self.update_filter)
1162988
def _recurmatch(path, aug):
    '''
    
    '''
    if path:
        clean_path = path.rstrip('/*')
        yield (clean_path, aug.get(path))

        for i in aug.match(clean_path + '/*'):
            i = i.replace('!', '\\!')  # escape some dirs
            for _match in _recurmatch(i, aug):
                yield _match
441205
function (name, detectorFn, imagePath) {
		var options = this.options,
		    prefix = options.classNamePrefix,
		    optionValues = detectorFn(prefix + name, imagePath);

		for (var optionName in optionValues) {
			options[name + optionName] = options[name + optionName] || optionValues[optionName];
		}
	}
502873
def filter_pypi(self, entry):
        """"""
        for package in self.packages:
            if entry.title.lower().startswith(package):
                return entry
840807
def detect(self, volume_system, vstype='detect'):
        """"""

        # Loop over all volumes in image.
        for p in self._find_volumes(volume_system, vstype):
            import pytsk3

            volume = volume_system._make_subvolume(
                index=self._format_index(volume_system, p.addr),
                offset=p.start * volume_system.disk.block_size,
                size=p.len * volume_system.disk.block_size
            )
            # Fill volume with more information
            volume.info['fsdescription'] = p.desc.strip().decode('utf-8')

            if p.flags == pytsk3.TSK_VS_PART_FLAG_ALLOC:
                volume.flag = 'alloc'
                volume.slot = _util.determine_slot(p.table_num, p.slot_num)
                volume_system._assign_disktype_data(volume)
                logger.info("Found allocated {2}: block offset: {0}, length: {1} ".format(p.start, p.len,
                                                                                          volume.info['fsdescription']))
            elif p.flags == pytsk3.TSK_VS_PART_FLAG_UNALLOC:
                volume.flag = 'unalloc'
                logger.info("Found unallocated space: block offset: {0}, length: {1} ".format(p.start, p.len))
            elif p.flags == pytsk3.TSK_VS_PART_FLAG_META:
                volume.flag = 'meta'
                logger.info("Found meta volume: block offset: {0}, length: {1} ".format(p.start, p.len))

            yield volume
43001
def __undo_filter_paeth(self, scanline):
        """"""
        ai = -self.fu
        previous = self.prev
        for i in range(len(scanline)):
            x = scanline[i]
            if ai < 0:
                pr = previous[i]  # a = c = 0
            else:
                a = scanline[ai]  # result
                c = previous[ai]
                b = previous[i]
                pa = abs(b - c)  # b
                pb = abs(a - c)  # 0
                pc = abs(a + b - c - c)  # b
                if pa <= pb and pa <= pc:  # False
                    pr = a
                elif pb <= pc:  # True
                    pr = b
                else:
                    pr = c
            scanline[i] = (x + pr) & 0xff  # result
            ai += 1