コード例 #1
0
def main():
    if len(sys.argv) > 2:
        usage_message()
        sys.exit(2)
    if len(sys.argv) == 1:
        try:
            with open('kb.fs19', 'w+') as f:
                f.write(raw_input())
                cin = f.name
        except IOError as x:
            if x.errno == errno.EACCES:
                print 'Error: Cannot write file'
                print 'Exiting...', sys.argv[0]
                sys.exit(1)
        filename = validate_file(str(cin))
        datum = parsing.parser(filename)
        #treetest.printing(datum,0)
        virtmach.virtual_machine(filename, datum, 0)
        print filename, 'makes proper use of its variables...'
    if len(sys.argv) == 2:
        filename = validate_file(str(sys.argv[1]))
        print filename, 'validated...'
        datum = parsing.parser(filename)
        #treetest.printing(datum,0)
        virtmach.virtual_machine(filename, datum, 0)
        print filename, 'initialized variables properly...'
コード例 #2
0
def find_locations(lat, lon, year):
    """
    Returns a list with 10 or less locations where films were casted
    in particular year, that are neareeest to given coordinates
    :param lat: float
    :param lon: float
    :param year: int
    :return: list
    """
    country = get_country(lat, lon)
    coordinates = parser("files/locations.list", year, country)
    print(coordinates, country, len(coordinates))
    distances = []
    for i in range(len(coordinates)):
        try:
            if 150 <= len(distances) or i >= 200:
                break
            location = locator.geocode(coordinates[i][0])
            film_lat, film_lon = (location.latitude, location.longitude)
            dis = geodesic((film_lat, film_lon), (lat, lon)).km
            distances.append([coordinates[i][1:], film_lat, film_lon, dis])
        except:
            continue

    distances.sort(key=lambda x: x[-1])
    print(len(distances))
    return distances[:10]
コード例 #3
0
def main():
    if len(sys.argv) > 2:
        usage_message()
        sys.exit(2)
    if len(sys.argv) == 1:
        try:
            with open('cin.fs19', 'w+') as f:
                f.write(raw_input())
                cin = f.name
        except IOError as x:
            if x.errno == errno.EACCES:
                print 'Error: Cannot write file'
                print 'Exiting...', sys.argv[0]
                sys.exit(1)
        filename = validate_file(str(cin))
        datum = parsing.parser(filename)
        treetest.printing(datum, 0)
    if len(sys.argv) == 2:
        filename = validate_file(str(sys.argv[1]))
        datum = parsing.parser(filename)
        treetest.printing(datum, 0)
コード例 #4
0
def parser_process(kw_text, st_text):
    save_config(int(kw_text.get()), int(st_text.get()))
    filename = filedialog.askopenfilename(filetypes=[("Excel files", ".xlsx")])
    logging.info(f'Выбран файл: {filename}.')
    if os.path.isfile(filename):
        result = parser(filename)
        if os.path.isfile(result[1]):
            messagebox.showinfo(
                title='Парсер',
                message=('Парсинг закончен\nОбработано строк:'
                         f' {result[0]}\nФайл сохранён\n{result[1]}'))
        else:
            messagebox.showerror(
                title='Парсер',
                message=('Парсинг закончен\nОбработано строк:'
                         f' {result[0]}\nФайл не сохранён!!!\n{result[1]}'))
コード例 #5
0
def train(key, sent):
    parsedSent = parser(sent)
    if key in botDict.keys():
        botDict[key].append((sent,parsedSent))
    else:
        botDict[key] = [(sent,parsedSent)]
コード例 #6
0
    
    else:
        myResponse = possibleResponses[random.randint(0,len(possibleResponses)-1)]
        #myResponse = possibleResponses[-1]
        print(myResponse[0])


'''                # original code for giving responses
#train("name", "My name's Lawrence! How are you today?")
train("name", "Hey I'm Lawrence.")


train("science", "Science is my favorite subject.")
train("science", "I hear the jury's still out on science.")
#'''

userInput = input("Hey! My name's Lawrence. Ask me a few questions, like what I think about science!\n")

userInput = userInput.lower()
parsedInput, sentenceType = parser(userInput)

while "bye" not in userInput:
    respond(parsedInput)
    userInput = input("Enter response: ")
    userInput = userInput.lower()
    parsedInput, sentenceType = parser(userInput)
else:
    print("Goodbye! See you later.")

with open('responses.p','wb') as f: # opens (and closes) file to write (w) as bytes (b)
    pickle.dump(botDict,f)
コード例 #7
0
ファイル: test.py プロジェクト: bradjrenshaw/calcbot
import parsing
import commands

info = {'name': 'calc', 'version': 0.1}

parser = parsing.parser(None, commands=commands.commands, info=info)

while True:
    text = raw_input("> ")
    print(parser.match(text))
コード例 #8
0
ファイル: convert.py プロジェクト: loicNorgeot/ICS_utils
            print "Non valid output extension: " + outExt

    else:
        print "Non valid input extension: " + inpExt



# Main execution
if __name__ == '__main__':
    import parsing
    import os
    import sys

    #Create an arguments parser
    description = "Converts files from and to mesh, stl and obj formats. Use either with -iDir, -oDir, -iExt and -oExt arguments to convert all files from a directory, or -i and -o arguments to convert a specific file."
    PARSER = parsing.parser(description)
    options = [("-iDir", "input directory",                 str),
               ("-oDir", "output directory",                str),
               ("-iExt", "input format ( stl, mesh, obj)",  str),
               ("-oExt", "output format ( stl, mesh, obj)", str),
               ("-i",    "input .mesh file",                str),
               ("-o",    "output .stl file",                str)]
    for opt in options:
        PARSER.add_argument( opt[0], opt[1], opt[2] )
    ARGS = PARSER.parse_args()

    #Post-processes the arguments and selects the case
    usage = None
    if ARGS.i != None and ARGS.o != None and ARGS.iDir == None and ARGS.oDir == None and ARGS.iExt == None and ARGS.oExt == None:
        usage = "file"
    elif ARGS.i == None and ARGS.o == None and ARGS.iDir != None and ARGS.oDir != None and ARGS.iExt != None and ARGS.oExt != None:
コード例 #9
0
ファイル: main.py プロジェクト: vitaliuchik/Concert_Notifier
import parsing

if __name__ == '__main__':
    api = Mobileclient()

    device_id = input("Input your Device ID: ")
    api.oauth_login(device_id)

    main_playlist = Playlist()

    library = api.get_all_songs()
    for song in library:
        main_playlist.append(song)

    playlists = api.get_all_user_playlist_contents()
    for playlist in playlists:
        for song in playlist['tracks']:
            main_playlist.append(song)

    top = main_playlist.top_n(5)
    artists = []
    for artist_id in top:
        artist = api.get_artist_info(include_albums=False,
                                     artist_id=artist_id,
                                     max_rel_artist=0,
                                     max_top_tracks=0)
        artists.append(artist['name'])

    for artist in artists:
        print(parsing.parser(artist))