prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>user_defined.py<|end_file_name|><|fim▁begin|># Author: Prabhu Ramachandran <prabhu [at] aero . iitb . ac . in> # Copyright (c) 2008, Enthought, Inc. # License: BSD Style. # Enthought library imports. from tvtk.tools.tvtk_doc import TVTKFilterChooser, TVTK_FILTERS # Local imports. from mayavi.filters.fil...
setup_filter
<|file_name|>user_defined.py<|end_file_name|><|fim▁begin|># Author: Prabhu Ramachandran <prabhu [at] aero . iitb . ac . in> # Copyright (c) 2008, Enthought, Inc. # License: BSD Style. # Enthought library imports. from tvtk.tools.tvtk_doc import TVTKFilterChooser, TVTK_FILTERS # Local imports. from mayavi.filters.fil...
_choose_filter
<|file_name|>user_defined.py<|end_file_name|><|fim▁begin|># Author: Prabhu Ramachandran <prabhu [at] aero . iitb . ac . in> # Copyright (c) 2008, Enthought, Inc. # License: BSD Style. # Enthought library imports. from tvtk.tools.tvtk_doc import TVTKFilterChooser, TVTK_FILTERS # Local imports. from mayavi.filters.fil...
_check_object
<|file_name|>user_defined.py<|end_file_name|><|fim▁begin|># Author: Prabhu Ramachandran <prabhu [at] aero . iitb . ac . in> # Copyright (c) 2008, Enthought, Inc. # License: BSD Style. # Enthought library imports. from tvtk.tools.tvtk_doc import TVTKFilterChooser, TVTK_FILTERS # Local imports. from mayavi.filters.fil...
_filter_changed
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
super(SchedulingComponentMixin, self).pause()
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
""" SchedulingComponent() -> new SchedulingComponent Base class for a threadedcomponent with an inbuilt scheduler, allowing a component to block until a scheduled event is ready or a message is received on an inbox. """ Inboxes = {"inbox" : "Standard inbox for receiving data from other c...
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
super(SchedulingComponentMixin, self).__init__(**argd) self.eventQueue = []
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
""" Schedule an event to wake the component and send a message to the "event" inbox after a delay. """ return self.scheduleAbs(message, time.time() + delay, priority)
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
""" Schedule an event to wake the component and send a message to the "event" inbox after at a specified time. """ event = eventTime, priority, message heapq.heappush(self.eventQueue, event) return event
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
""" Remove a scheduled event from the scheduler """ self.eventQueue.remove(event) heapq.heapify(self.eventQueue)
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
""" Returns true if there is an event ready to be processed """ if self.eventQueue: eventTime = self.eventQueue[0][0] if time.time() >= eventTime: return True return False
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
""" Sleep until there is either an event ready or a message is received on an inbox """ if self.eventReady(): self.signalEvent() else: if self.eventQueue: eventTime = self.eventQueue[0][0] super(SchedulingComponentMi...
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
""" Put the event message of the earliest scheduled event onto the component's "event" inbox and remove it from the scheduler. """ eventTime, priority, message = heapq.heappop(self.eventQueue) #print "Signalling, late by:", (time.time() - eventTime) if not self.in...
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
def __init__(self, **argd): super(SchedulingComponent, self).__init__(**argd)
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
super(SchedulingComponent, self).__init__(**argd)
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
def __init__(self, **argd): super(SchedulingAdaptiveCommsComponent, self).__init__(**argd)
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
super(SchedulingAdaptiveCommsComponent, self).__init__(**argd)
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
eventTime = self.eventQueue[0][0] if time.time() >= eventTime: return True
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
return True
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
self.signalEvent()
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
if self.eventQueue: eventTime = self.eventQueue[0][0] super(SchedulingComponentMixin, self).pause(eventTime - time.time()) if self.eventReady(): self.signalEvent() else: super(SchedulingComponentMixin, self).paus...
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
eventTime = self.eventQueue[0][0] super(SchedulingComponentMixin, self).pause(eventTime - time.time()) if self.eventReady(): self.signalEvent()
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
self.signalEvent()
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
super(SchedulingComponentMixin, self).pause()
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
self.inqueues["event"].put(message)
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
__init__
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
scheduleRel
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
scheduleAbs
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
cancelEvent
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
eventReady
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
pause
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
signalEvent
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
__init__
<|file_name|>SchedulingComponent.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1) # # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this not...
__init__
<|file_name|>json.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import import json class JSONRenderer:<|fim▁hole|> """ def render(self, mystery): return json.dumps(mystery.encode(), indent=4)<|fim▁end|>
""" Renders a mystery as JSON
<|file_name|>json.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import import json class JSONRenderer: <|fim_middle|> <|fim▁end|>
""" Renders a mystery as JSON """ def render(self, mystery): return json.dumps(mystery.encode(), indent=4)
<|file_name|>json.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import import json class JSONRenderer: """ Renders a mystery as JSON """ def render(self, mystery): <|fim_middle|> <|fim▁end|>
return json.dumps(mystery.encode(), indent=4)
<|file_name|>json.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import import json class JSONRenderer: """ Renders a mystery as JSON """ def <|fim_middle|>(self, mystery): return json.dumps(mystery.encode(), indent=4) <|fim▁end|>
render
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|><|fim▁hole|><|fim▁end|>
default_app_config = "gallery.apps.GalleryConfig"
<|file_name|>Squares.py<|end_file_name|><|fim▁begin|>#David Hickox #Feb 15 17 #Squares (counter update) #descriptions, description, much descripticve #variables # limit, where it stops # num, sentry variable #creates array if needbe #array = [[0 for x in range(h)] for y in range(w)] #imports date time and curenc...
input("\nPress Enter to Exit")
<|file_name|>finddata.py<|end_file_name|><|fim▁begin|>import pathlib<|fim▁hole|>__all__ = ['sample', 'sampleTxt', 'sampleBin'] this = pathlib.Path(__file__) datadir = this.parent.parent / 'data' loader = importlib.machinery.SourceFileLoader('sample', str(datadir / 'sample.py')) sample = loader.load_module() sampleTxt...
import importlib import sys
<|file_name|>behaviors.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import print_function import sys import re from utils import CDNEngine from utils import request if sys.version_info >= (3, 0): import subprocess as commands import urllib.parse as urlparse else: import commands ...
if res is not None and res.status_code == 500: CDNEngine.find(res.text.lower())
<|file_name|>behaviors.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import print_function import sys import re from utils import CDNEngine from utils import request if sys.version_info >= (3, 0): import subprocess as commands import urllib.parse as urlparse else: import commands ...
""" Performs CDN detection thanks to information disclosure from server error. Parameters ---------- hostname : str Hostname to assess """ print('[+] Error server detection\n') hostname = urlparse.urlparse(hostname).netloc regexp = re.compile('\\b\d{1,3}\.\d{1,3}\.\d{1,3}\...
<|file_name|>behaviors.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import print_function import sys import re from utils import CDNEngine from utils import request if sys.version_info >= (3, 0): <|fim_middle|> else: import commands import urlparse def detect(hostname): ...
import subprocess as commands import urllib.parse as urlparse
<|file_name|>behaviors.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import print_function import sys import re from utils import CDNEngine from utils import request if sys.version_info >= (3, 0): import subprocess as commands import urllib.parse as urlparse else: <|fim_middle|...
import commands import urlparse
<|file_name|>behaviors.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import print_function import sys import re from utils import CDNEngine from utils import request if sys.version_info >= (3, 0): import subprocess as commands import urllib.parse as urlparse else: import commands ...
CDNEngine.find(res.text.lower())
<|file_name|>behaviors.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import print_function import sys import re from utils import CDNEngine from utils import request if sys.version_info >= (3, 0): import subprocess as commands import urllib.parse as urlparse else: import commands ...
detect
<|file_name|>banner.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import time <|fim▁hole|> print '[*] swarm starting at '+time.strftime(timeformat,time.localtime()) print '' def end_banner(): print '' print '[*] swarm shutting down at '+time.strftime(timeformat,time.loca...
timeformat='%H:%M:%S' def begin_banner(): print ''
<|file_name|>banner.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import time timeformat='%H:%M:%S' def begin_banner(): <|fim_middle|> def end_banner(): print '' print '[*] swarm shutting down at '+time.strftime(timeformat,time.localtime()) print ''<|fim▁end|>
print '' print '[*] swarm starting at '+time.strftime(timeformat,time.localtime()) print ''
<|file_name|>banner.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import time timeformat='%H:%M:%S' def begin_banner(): print '' print '[*] swarm starting at '+time.strftime(timeformat,time.localtime()) print '' def end_banner(): <|fim_middle|> <|fim▁end|>
print '' print '[*] swarm shutting down at '+time.strftime(timeformat,time.localtime()) print ''
<|file_name|>banner.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import time timeformat='%H:%M:%S' def <|fim_middle|>(): print '' print '[*] swarm starting at '+time.strftime(timeformat,time.localtime()) print '' def end_banner(): print '' print '[*] swarm shutti...
begin_banner
<|file_name|>banner.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import time timeformat='%H:%M:%S' def begin_banner(): print '' print '[*] swarm starting at '+time.strftime(timeformat,time.localtime()) print '' def <|fim_middle|>(): print '' print '[*] swarm shut...
end_banner
<|file_name|>generate_make.py<|end_file_name|><|fim▁begin|>""" ``editquality generate_make -h`` :: Code-generate Makefile from template and configuration :Usage: generate_make -h | --help generate_make [--config=<path>] [--main=<filename>] ...
if not os.path.isabs(main_template_path):
<|file_name|>generate_make.py<|end_file_name|><|fim▁begin|>""" ``editquality generate_make -h`` :: Code-generate Makefile from template and configuration :Usage: generate_make -h | --help generate_make [--config=<path>] [--main=<filename>] ...
args = docopt.docopt(__doc__, argv=argv) logging.basicConfig( level=logging.DEBUG if args['--debug'] else logging.WARNING, format='%(asctime)s %(levelname)s:%(name)s -- %(message)s' ) config_path = args["--config"] output_f = sys.stdout \ if args["--output"] == "<stdout>" ...
<|file_name|>generate_make.py<|end_file_name|><|fim▁begin|>""" ``editquality generate_make -h`` :: Code-generate Makefile from template and configuration :Usage: generate_make -h | --help generate_make [--config=<path>] [--main=<filename>] ...
main_template_path = os.path.join(templates_path, main_template_path)
<|file_name|>generate_make.py<|end_file_name|><|fim▁begin|>""" ``editquality generate_make -h`` :: Code-generate Makefile from template and configuration :Usage: generate_make -h | --help generate_make [--config=<path>] [--main=<filename>] ...
main
<|file_name|>time.py<|end_file_name|><|fim▁begin|>from .game import Board for i in range(10): Board.all()<|fim▁hole|><|fim▁end|>
print(i)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
if os.path.isfile(new_filename): if _compare_files(old_filename, new_filename):
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
parser = argparse.ArgumentParser() parser.add_argument('config', help='JSON configuration file') parser.add_argument('--only-download', action='store_true', help='Only download GTFS file') parser.add_argument('--use-no-q-dirs', action='store_true', help='Do not use Q dirs') args = parser.parse_args(...
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
log_format = '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(funcName)s: %(message)s' logging.basicConfig(filename='generate.log', format=log_format, level=logging.DEBUG)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
print(text) logging.debug(text)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
print('\033[31m{}\033[0m'.format(text)) logging.warning(text)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
with open(config_path) as config_file: return json.load(config_file)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
output_file, output_filename = tempfile.mkstemp(dir='.') os.close(output_file) curl_options = '--header "Accept-Encoding: gzip" --location' command = 'curl {} "{}" > {}'.format(curl_options, url, output_filename) _progress('downloading gtfs file into: {}'.format(os.path.relpath(output_filename))) ...
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
if os.system(command) != 0: raise SystemExit('failed to execute: {}'.format(command))
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
modify_times = _get_modify_times(zip_filename) if len(modify_times) > 1: _progress_warning('multiple modify times: {}'.format(modify_times)) return sorted(modify_times)[-1]
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
modify_times = set() with zipfile.ZipFile(zip_filename) as zip_file: for info in zip_file.infolist(): modify_times.add(datetime.datetime(*info.date_time).strftime('%Y%m%d')) return modify_times
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
if create_q_dir: modify_month = int(modify_date[4:6]) q_dir = '{}_q{}'.format(modify_date[:4], 1 + ((modify_month - 1) // 3)) return os.path.join(base_dir, q_dir) return base_dir
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_create_dir(gtfs_dir) new_filename = os.path.join(gtfs_dir, '{}_{}.zip'.format(gtfs_name, modify_date)) if os.path.isfile(new_filename): if _compare_files(old_filename, new_filename): _progress('downloaded gtfs file is identical to: {}'.format(new_filename)) os.remove(old_fil...
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
if not os.path.isdir(new_dir): os.makedirs(new_dir)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
return _get_hash(filename_a) == _get_hash(filename_b)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
file_hash = hashlib.sha256() with open(filename, 'rb') as input_file: file_hash.update(input_file.read()) return file_hash.digest()
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_create_dir(json_dir) date_output_file = os.path.join(json_dir, '{}_{}.json'.format(gtfs_name, modify_date)) _rename_existing_file(date_output_file) _create_dir(log_dir) log_path = os.path.join(log_dir, 'gtfs2json_{}_{}_{}.log'.format(gtfs_name, modify_date, ...
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
if os.path.isfile(base_output_file): _progress('deleting {}'.format(base_output_file)) os.remove(base_output_file) _progress('copying {} to {}'.format(date_output_file, base_output_file)) shutil.copyfile(date_output_file, base_output_file)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
if os.path.isfile(filename): suffix = filename.split('.')[-1] new_filename = filename.replace('.{}'.format(suffix), '_{}.{}'.format(_get_now_timestamp(), suffix)) os.rename(filename, new_filename) _progress_warning('renamed existing {} file {} ...
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
return datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
log_dir = _get_q_dir(config['log_dir'], modify_date, not args.use_no_q_dirs) _generate_json(gtfs_name, modify_date, gtfs_zip, config['json_dir'], log_dir)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
raise SystemExit('failed to execute: {}'.format(command))
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_progress_warning('multiple modify times: {}'.format(modify_times))
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
modify_month = int(modify_date[4:6]) q_dir = '{}_q{}'.format(modify_date[:4], 1 + ((modify_month - 1) // 3)) return os.path.join(base_dir, q_dir)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
if _compare_files(old_filename, new_filename): _progress('downloaded gtfs file is identical to: {}'.format(new_filename)) os.remove(old_filename) return None
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_progress('downloaded gtfs file is identical to: {}'.format(new_filename)) os.remove(old_filename) return None
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
os.makedirs(new_dir)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_progress('deleting {}'.format(base_output_file)) os.remove(base_output_file)
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
suffix = filename.split('.')[-1] new_filename = filename.replace('.{}'.format(suffix), '_{}.{}'.format(_get_now_timestamp(), suffix)) os.rename(filename, new_filename) _progress_warning('renamed existing {} file {} -> {}'.format(suffix, filename, ...
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_main()
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_main
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_init_logging
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_progress
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_progress_warning
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_load_config
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_download_gtfs
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_execute_command
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_get_modify_date
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_get_modify_times
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_get_q_dir
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_rename_gtfs_zip
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_create_dir
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_compare_files
<|file_name|>generate.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 """Download GTFS file and generate JSON file. Author: Panu Ranta, panu.ranta@iki.fi, https://14142.net/kartalla/about.html """ import argparse import datetime import hashlib import json import logging import os import resource import shutil...
_get_hash