Exemple #1
0
 def checkYear(self):
     findYear = Parser(self.stringToScan.lower(), '1st|2nd|3rd|4th|5th|6th')
     if findYear.doesMatchExist():
         years = []
         for i in findYear.getResult():
             years.append('%s Year' % i)
         return years
 def __init__(self, game):
     Parser.__init__(self, "Contact Delay")
     if "Contact" not in game.missions_complete:
         self.complete = True
     else:
         self.rbbts = 0
         self.results = [[], []]
Exemple #3
0
 def __init__(self, game):
     Parser.__init__(self, "Added Time Usage")
     if not game.reaches_mwc:
         self.complete = True
     else:
         self.start_clock = game.clock
         self.time_added = 0
Exemple #4
0
    def getMajors(self):
        if self.checkContext(
                'enrolled in|majoring in|program|major|concentration|pursuing|student|study\sof') and self.doesMatchExist():
            for i in self.getResult():
                self.resultList.append(i)

        if self.checkContext('of\sscience|of\sarts|of\smedicine') and self.doesMatchExist():
            if 'science' in self.resultList:
                self.resultList.remove('science')
            if 'arts' in self.resultList:
                self.resultList.remove('arts')
            if 'medicine' in self.resultList:
                self.resultList.remove('medicine')

        if self.checkContext('engineering'):
            tokenizeEngineeringString = re.findall(r"[\w']+", self.stringToScan)
            for i in range(len(tokenizeEngineeringString)):
                if tokenizeEngineeringString[i] == 'engineering':
                    engineeringContextSlice = tokenizeEngineeringString[i - 5:i]
                    concatenateEngineeringWithWord = []
                    for i in engineeringContextSlice:
                        concatenateEngineeringWithWord.append('%s engineering' % i)

                    for i in concatenateEngineeringWithWord:
                        checkEngineeringMajors = Parser(i, self.majorsRegex)
                        if checkEngineeringMajors.doesMatchExist():
                            for i in checkEngineeringMajors.getResult():
                                self.resultList.append(i)
                                if 'engineering' in self.resultList:
                                    self.resultList.remove('engineering')

        self.resultList = list(set(self.resultList))

        self.major = ', '.join(self.resultList)
        return self.major
Exemple #5
0
 def __init__(self, stringToScan):
     Parser.stringToScan = stringToScan
     Parser.__init__(
         self, self.stringToScan,
         '(?:\s|\>)[mM]ale|(?:\s|\>)+[Ff]emale|(?:\s|\>)+[Ww]omen|(?:\s|\>)+[Mm]en'
     )
     self.resultList = []
Exemple #6
0
def main():
    parser = argparse.ArgumentParser(description='n-puzzle')
    parser.add_argument('-d',
                        '--distance-metric',
                        help='Distance function',
                        choices=['simple', 'manhattan', 'euclead'],
                        default='manhattan')
    parser.add_argument('-v',
                        '--verbose',
                        help='Verbose intermediate results',
                        action='store_true')
    parser.add_argument('-g',
                        '--greedy',
                        help='Use greedy algorithm',
                        action='store_true')
    parser.add_argument('-u',
                        '--uniform',
                        help='Use uniform cost',
                        action='store_true')
    parser.add_argument('file', help='input file')
    parser = parser.parse_args()

    try:
        data_parser = Parser(file_name=parser.file)
        node = Node(puzzle_data=data_parser.get_data(),
                    metric=parser.distance_metric,
                    print_inter_res=parser.verbose,
                    greedy=parser.greedy,
                    uniform_cost=parser.uniform)
        game = Game(start_node=node)
        game.solve()
        exit(0)
    except ValueError as error:
        print(error)
        exit(2)
Exemple #7
0
 def checkYear(self):
     findYear = Parser(self.stringToScan.lower(), '1st|2nd|3rd|4th|5th|6th')
     if findYear.doesMatchExist():
         years = []
         for i in findYear.getResult():
             years.append('%s Year' % i)
         return years
Exemple #8
0
    def __init__(self, stringToScan, attributeId):

        self.attributeId = attributeId
        self.IsMatched = False
        self.stringToScan = stringToScan
        self.searchCriteria = DatabaseHelper.getOnlyOneRegex(self.attributeId)
        Parser.__init__(self, stringToScan, self.searchCriteria)
        self.IsMatched = self.doesMatchExist()
Exemple #9
0
 def __init__(self, game):
     Parser.__init__(self, "Clock Usage")
     self.start_clock = game.clock
     self.end_clock = game.timeline.events[-3].time
     # this does not violate the parallelization because it is an index, not a loop
     self.results = str(round(100*self.end_clock/self.start_clock, 1))+"%"
     # currently returns a percent (string) of clock time used, how is this a good idea
     # in fact, this is so easily computed, it was possible without the timeline at all (via spyparsey)
     self.complete = True
Exemple #10
0
 def __init__(self, stringToScan, scholarshipPackageId='0'):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, '\s[^$\d\.]?[1234]\.\d+')
     self.resultList = []
     self.attributeId = '1'
     self.gpa = ''
     self.logicGroup = '0'
     self.requirementTypeCode = '>='
     self.scholarshipPackageId = scholarshipPackageId
Exemple #11
0
 def __init__(self, stringToScan, scholarshipPackageId='0'):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, '\s[^$\d\.]?[1234]\.\d+')
     self.resultList = []
     self.attributeId = '1'
     self.gpa = ''
     self.logicGroup = '0'
     self.requirementTypeCode = '>='
     self.scholarshipPackageId = scholarshipPackageId
Exemple #12
0
 def __init__(self, stringToScan, uaColleges, scholarshipPackageId='0'):
     self.uaColleges = uaColleges
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.uaColleges)
     self.resultList = []
     self.attributeId = '377'
     self.requirementValue = ''
     self.logicGroup = '0'
     self.requirementTypeCode = '*'
     self.scholarshipPackageId = scholarshipPackageId
Exemple #13
0
 def __init__(self, stringToScan, uaColleges, scholarshipPackageId='0'):
     self.uaColleges = uaColleges
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.uaColleges)
     self.resultList = []
     self.attributeId = '377'
     self.requirementValue = ''
     self.logicGroup = '0'
     self.requirementTypeCode = '*'
     self.scholarshipPackageId = scholarshipPackageId
Exemple #14
0
 def __init__(self, stringToScan, majorsRegex, scholarshipPackageId='0'):
     self.majorsRegex = majorsRegex
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(), self.majorsRegex)
     self.resultList = []
     self.attributeId = '417'
     self.major = ''
     self.logicGroup = '0'
     self.requirementTypeCode = '*'
     self.scholarshipPackageId = scholarshipPackageId
    def getEmploymentStatus(self):
        if self.checkContext('work|employ|job'):
            if self.doesMatchExist():
                for i in self.getResult():
                    self.resultList.append(i)
            elif self.checkContext('hour'):
                findHours = Parser(self.stringToScan, '\d{1,2}')
                if findHours.doesMatchExist():
                    for i in findHours.getResult():
                        self.resultList.append('%s Hours' % i)

        self.resultList = list(set(self.resultList))
        return self.resultList
    def getEmploymentStatus(self):
        if self.checkContext('work|employ|job'):
            if self.doesMatchExist():
                for i in self.getResult():
                    self.resultList.append(i)
            elif self.checkContext('hour'):
                findHours = Parser(self.stringToScan, '\d{1,2}')
                if findHours.doesMatchExist():
                    for i in findHours.getResult():
                        self.resultList.append('%s Hours' % i)

        self.resultList = list(set(self.resultList))
        return self.resultList
Exemple #17
0
    def __checkPublicIP(self):
        try:
            hdr = {'User-Agent': 'Mozilla/5.0'}
            req = urllib.request.Request('http://www.cualesmiip.com',
                                         headers=hdr)

            try:
                page = urllib.request.urlopen(req)
            except urllib.error.HTTPError as e:
                #print(e.fp.read())
                pass

            myParser = Parser()
            myParser.feed(str(page.read()))
            page.close()

            return myParser.result

        except Exception as e:
            #page.close()
            print(e)
Exemple #18
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "f", ["file"])
    except getopt.error as msg:
        print(msg)
        print("It is necessary file :((")
        sys.exit(2)
    for arg in args:
        try:
            parser = Parser(file_name=arg)
            node = Node(puzzle_data=parser.get_data(), metric='simple')
            game = Game(start_node=node)
            game.solve()
            exit(0)
        except ValueError as error:
            print(error)
            exit(2)
    parser = Parser()
    node = Node(puzzle_data=parser.get_data(), metric='euclead')
    game = Game(start_node=node)
    game.solve()
Exemple #19
0
 def checkDueDateContext(self):
     contextRegex = 'due\sdate|application\swindow|deadline|dead\sline|close\sdate|close|closing\sdate'
     contextChecker = Parser(self.stringToScan.lower(), contextRegex)
     return contextChecker.doesMatchExist()
Exemple #20
0
 def __init__(self, stringToScan, demographics):
     self.demographics = demographics
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.demographics)
     self.resultList = []
Exemple #21
0
 def __init__(self, stringToScan):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(), 'fafsa')
     self.resultList = []
Exemple #22
0
 def __init__(self, stringToScan, classStandingOptions):
     self.classStandingOptions = classStandingOptions
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(), self.classStandingOptions)
     self.resultList = []
Exemple #23
0
 def __init__(self, stringToScan, states):
     self.states = states
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.states)
     self.resultList = []
 def __init__(self, stringToScan, arizonaCounties):
     self.arizonaCounties = arizonaCounties
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.arizonaCounties)
     self.resultList = []
Exemple #25
0
 def __init__(self, stringToScan, states):
     self.states = states
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.states)
     self.resultList = []
Exemple #26
0
 def __init__(self, stringToScan, countriesNationalities):
     self.countriesNationalities = countriesNationalities
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.countriesNationalities)
     self.resultList = []
Exemple #27
0
 def checkContext(self, contextRegex):
     contextChecker = Parser(self.stringToScan.lower(), contextRegex)
     return contextChecker.doesMatchExist()
Exemple #28
0
 def __init__(self, stringToScan):
     Parser.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, '(?:\s|\>)[mM]ale|(?:\s|\>)+[Ff]emale|(?:\s|\>)+[Ww]omen|(?:\s|\>)+[Mm]en')
     self.resultList = []
 def __init__(self, stringToScan, arizonaCounties):
     self.arizonaCounties = arizonaCounties
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.arizonaCounties)
     self.resultList = []
Exemple #30
0
 def test_ParserFailure(self):
     failparser = Parser('This test should return false', 'chicken')
     self.assertIsNotNone(failparser)
     self.assertEqual(failparser.doesMatchExist(), False)
Exemple #31
0
 def checkGraduate(self):
     if not self.checkContext('graduate\sfrom|graduates'):
         findGraduate = Parser(self.stringToScan.lower(), '^graduate|\sgraduate')
         if findGraduate.doesMatchExist():
             return ['graduate']
Exemple #32
0
 def __init__(self, stringToScan, aboutMeAttributes):
     self.aboutMeAttributes = aboutMeAttributes
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(),
                     self.aboutMeAttributes)
     self.resultList = []
Exemple #33
0
    log_main.warning('Limpando Cache Control ...')
    cache_control.clear()

    if server is not None:
        log_main.warning('Parando Serviço ...')
        server.stop()
    if execute:
        execute = False
    else:
        sys.exit(2)


if __name__ == '__main__':
    execute = True
    workdir = Utils.get_workdir()
    conf = Parser(os.path.join(workdir, 'config.ini')).conf_get()
    _level = conf.getint('Debug', 'Level', fallback=3)
    debug_dir = os.path.join(workdir, 'debug')
    log_file_path = os.path.join(debug_dir, 'TrashAlert.log')
    if not os.path.exists(debug_dir):
        os.mkdir(debug_dir, 0o775)
    log_handler = RotatingFileHandler(log_file_path,
                                      maxBytes=1024 * 1024 * 10,
                                      backupCount=10)
    log_handler.setLevel(logging.DEBUG)
    log_handler.setFormatter(
        RequestFormatter(
            '[%(asctime)s] | %(levelname)s | %(name)s | %(remote_addr)s | %(method)s | %(url)s | %(message)s'
        ))
    root_logger = logging.getLogger()
    root_logger.setLevel(logging.DEBUG)
Exemple #34
0
 def checkGraduate(self):
     if not self.checkContext('graduate\sfrom|graduates'):
         findGraduate = Parser(self.stringToScan.lower(),
                               '^graduate|\sgraduate')
         if findGraduate.doesMatchExist():
             return ['graduate']
Exemple #35
0
 def __init__(self, stringToScan):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, '\s\d{1,3}\s')
     self.resultList = []
Exemple #36
0
 def __init__(self, stringToScan, interestsAndActivities):
     self.interestsAndActivities = interestsAndActivities
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(), self.interestsAndActivities)
     self.resultList = []
Exemple #37
0
 def __init__(self, stringToScan, demographics):
     self.demographics = demographics
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, self.demographics)
     self.resultList = []
Exemple #38
0
 def __init__(self, stringToScan, classStandingOptions):
     self.classStandingOptions = classStandingOptions
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(),
                     self.classStandingOptions)
     self.resultList = []
Exemple #39
0
 def checkContext(self, contextCriteria):
     contextChecker = Parser(self.stringToScan.lower(), contextCriteria)
     return contextChecker.doesMatchExist()
Exemple #40
0
 def __init__(self, stringToScan):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(), 'fafsa')
     self.resultList = []
 def __init__(self, stringToScan):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan,
                     'full\-time|part\-time|full\stime|part\stime')
     self.resultList = []
Exemple #42
0
 def __init__(self, stringToScan):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, '\s\d{1,3}\s')
     self.resultList = []
 def __init__(self, stringToScan):
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan, 'full\-time|part\-time|full\stime|part\stime')
     self.resultList = []
Exemple #44
0
 def __init__(self, stringToScan, aboutMeAttributes):
     self.aboutMeAttributes = aboutMeAttributes
     self.stringToScan = stringToScan
     Parser.__init__(self, self.stringToScan.lower(), self.aboutMeAttributes)
     self.resultList = []
Exemple #45
0
 def test_Parser(self):
     testparser = Parser('This is a test', 'test')
     self.assertIsNotNone(testparser)
     self.assertEqual(testparser.doesMatchExist(), True)
     self.assertEqual(testparser.getResult(), ['test'])
Exemple #46
0
 def checkContext(self, contextCriteria):
     return Parser(self.stringToScan.lower(),
                   contextCriteria).doesMatchExist()