本文整理汇总了Python中BaseObject.BaseObject类的典型用法代码示例。如果您正苦于以下问题:Python BaseObject类的具体用法?Python BaseObject怎么用?Python BaseObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, **kwargs):
BaseObject.__init__(self, **kwargs)
Config.__init__(self, **kwargs)
logger_setup = kwargs.get("logger_setup", self.GLOBAL_CONFIG.get("logger_setup"))
if logger_setup is not None:
kwargs = logger_setup
if not kwargs.get("log_filename"):
appname = self.GLOBAL_CONFIG.get("app_name")
if appname is not None:
kwargs.setdefault("log_filename", os.path.expanduser("~/%s.log" % (appname)))
self._logger = None
use_conf = kwargs.get("use_conf", True)
if use_conf:
d = self.get_conf()
else:
d = {}
for key in self._confkeys:
val = d.get(key)
if val is None:
val = kwargs.get(key)
if val is None:
continue
setattr(self, key, val)
self.logger_kwargs = kwargs.get("logger_kwargs", {})
self.set_logger()
self.bind(property_changed=self._on_own_property_changed)
示例2: __init__
def __init__(self, accept, username="", password="", uid="", process_id="",
audioFilename="", metadataFilename="", transcriptFilename="",
service=None, item_id=None, count=None):
BaseObject.__init__(self, accept, username=username, password=password, uid=uid, process_id=process_id,
audioFilename=audioFilename, metadataFilename=metadataFilename, transcriptFilename=transcriptFilename,
service=service, item_id=item_id, count=count)
self.path = 'transcripts/'
示例3: __init__
def __init__(self, attr):
BaseObject.__init__(self, attr['name'], 'square')
SfSceneComponent.__init__(self, attr.get('pixmap', ''))
self._min = attr.get('min', 0)
self._max = attr.get('max', 0)
self._value = float(self.getMin())
self._stepSize= 0.01
示例4: __init__
def __init__(
self,
accept,
username="",
password="",
uid="",
process_id="",
audioFilename=None,
metadataFilename=None,
transcriptFilename=None,
service=None,
item_id=None,
count=None,
status=None,
):
BaseObject.__init__(
self,
accept,
username=username,
password=password,
uid=uid,
process_id=process_id,
audioFilename=audioFilename,
metadataFilename=metadataFilename,
transcriptFilename=transcriptFilename,
service=service,
item_id=item_id,
count=count,
status=status,
)
self.path = "media/"
self.path_trans = "/transcribe"
self.path_publish = "/publish"
self.path_unpublish = "/unpublish"
示例5: import_agencies
def import_agencies(cls, directory):
try:
f = open(os.path.join(directory, 'agency.txt'), 'rb')
reader = csv.reader(f)
mappings = {'agency_name': 'name',
'agency_url': 'url',
'agency_timezone': 'timezone',
'agency_lang': 'language',
'agency_phone': 'phone',
'agency_fare_url': 'fare_url'}
# create a headers with an index
headers = reader.next()
r_headers = dict([(x, i) for i, x in enumerate(headers)])
for l2 in reader:
if len(l2) != len(headers):
print >> sys.stderr, 'Invalid line', l2, headers
continue
kw = {}
for i, a in enumerate(l2):
key = headers[i]
if key in mappings:
kw[mappings[key]] = BaseObject.unquote(a)
# create the agency
agency = Agency(**kw)
# set the id
agency.gtfs_id = BaseObject.unquote(l2[r_headers['agency_id']])
except IOError, e:
print >> sys.stderr, 'Unable to open agency.txt:', e
示例6: transcribe
def transcribe(self, success_callback_url="", error_callback_url=""):
print >>sys.stderr, "making post request to: %s%s" % (self.dest, self.path + self.uid + self.path_trans)
data = urllib.urlencode(
{"success_callback_url": success_callback_url, "error_callback_url": error_callback_url}
)
request = urllib2.Request(self.dest + self.path + self.uid + self.path_trans, data=data, headers=self.headers)
BaseObject._execute(self, request)
示例7: transcribe
def transcribe(self):
print >> sys.stderr, 'making post request to: %s%s' % (self.dest,self.path+self.uid+self.path_trans)
self.datagen = {}
#print >> sys.stderr, self.username, self.password
#print >> sys.stderr, type(self.uid)
#print >> sys.stderr, type(self.path)
request = urllib2.Request(self.dest+self.path+self.uid+self.path_trans, data="", headers=self.headers)
BaseObject._execute(self, request)
示例8: __init__
def __init__(self, name, coords = None):
BaseObject.__init__(self)
self.path_id = Path.new_id()
self.name = name
self.coords = coords
# add us
Path.paths.append(self)
示例9: __init__
def __init__(self, trip_route, start, end, headway):
BaseObject.__init__(self)
self.frequency_id = Frequency.new_id()
self.start = start
self.end = end
self.headway = headway
self._trip_route = weakref.ref(trip_route)
# add us
Frequency.frequencies.append(self)
示例10: publish
def publish(self):
print >>sys.stderr, "making put request to: %s%s" % (self.dest, self.path + self.uid + self.path_publish)
data = {}
if self.service:
data.update({"service_name": self.service})
data = urllib.urlencode(data)
url = "%s/%s/%s/%s?%s" % (self.dest, self.path, self.uid, self.path_publish, data)
request = urllib2.Request(url, data="", headers=self.headers)
request.get_method = lambda: "PUT"
BaseObject._execute(self, request)
示例11: __init__
def __init__(self, **kwargs):
BaseObject.__init__(self, **kwargs)
Config.__init__(self, **kwargs)
self._default_filetype = None
self._mimetypes = mimetypes.MimeTypes()
self.filetypes = {}
filetype_data = kwargs.get('filetype_data', [])
for data in filetype_data:
self.add_filetype(**data)
self.recent_files = {}
self.files_by_path = {}
self.get_recent_files()
self.bind(current_file=self._on_current_file_set)
示例12: __init__
def __init__(self, name = None, url = None,
timezone = 'America/Chicago', language = 'EN', phone = None, fare_url = None):
BaseObject.__init__(self)
self.agency_id = Agency.new_id()
self.name = name
self.url = url
self.timezone = timezone
self.language = language
self.phone = phone
self.fare_url = fare_url
# add us
Agency.agencies.append(self)
示例13: import_trips
def import_trips(cls, directory):
from Route import Route
from Calendar import Calendar
from TripRoute import TripRoute
from Path import Path
from Stop import Stop
try:
f = open(os.path.join(directory, 'trips.txt'), 'rb')
reader = csv.reader(f)
mappings = {'route_id': ('route', lambda x: Route.get_by_gtfs_id(x)),
'service_id': ('calendar', lambda x: Calendar.get_by_gtfs_id(x)),
'trip_id': ('name', lambda x: x),
'trip_headsign': ('headsign', lambda x: x),
'direction_id': ('direction', lambda x: int(x) if x else 0),
'shape_id': ('path', lambda x: Path.get_by_gtfs_id(x)),
}
# create a headers with an index
headers = reader.next()
r_headers = dict([(x, i) for i, x in enumerate(headers)])
for l2 in reader:
if len(l2) != len(headers):
print >> sys.stderr, 'Invalid line', l2, headers
continue
kw = {}
for i, a in enumerate(l2):
key = headers[i]
if key in mappings:
kw[mappings[key][0]] = mappings[key][1](BaseObject.unquote(a))
# create the trip route
trip_route = TripRoute(**kw)
# set the id
trip_route.gtfs_id = BaseObject.unquote(l2[r_headers['trip_id']])
# create a trip
trip = trip_route.add_trip()
trip.gtfs_id = BaseObject.unquote(l2[r_headers['trip_id']])
# go through the list again and set block ids
#!mwd - I'm not sure how to do this. We link
# blocks by trip ids, but block ids are
# random in gtfs, so we have no way to link
# them back
except IOError, e:
print >> sys.stderr, 'Unable to open trips.txt:', e
示例14: import_calendars
def import_calendars(cls, directory):
try:
f = open(os.path.join(directory, 'calendar.txt'), 'rb')
reader = csv.reader(f)
mappings = {'service_id': 'service_name',
'monday': 'monday',
'tuesday': 'tuesday',
'wednesday': 'wednesday',
'thursday': 'thursday',
'friday': 'friday',
'saturday': 'saturday',
'sunday': 'sunday',
'start_date': 'start_date',
'end_date': 'end_date',
}
transforms = {'service_id': lambda x: x,
'monday': lambda x: int(x),
'tuesday': lambda x: int(x),
'wednesday': lambda x: int(x),
'thursday': lambda x: int(x),
'friday': lambda x: int(x),
'saturday': lambda x: int(x),
'sunday': lambda x: int(x),
'start_date': lambda x: x,
'end_date': lambda x: x,
}
# create a headers with an index
headers = reader.next()
r_headers = dict([(x, i) for i, x in enumerate(headers)])
for l2 in reader:
if len(l2) != len(headers):
print >> sys.stderr, 'Invalid line', l2, headers
continue
kw = {}
for i, a in enumerate(l2):
key = headers[i]
if key in mappings:
kw[mappings[key]] = transforms[key](BaseObject.unquote(a))
# create the calendar
calendar = Calendar(**kw)
# set the id
calendar.gtfs_id = BaseObject.unquote(l2[r_headers['service_id']])
except IOError, e:
print >> sys.stderr, 'Unable to open calendar.txt:', e
示例15: __init__
def __init__(self, name, trip_route, calendar):
BaseObject.__init__(self)
self.trip_id = Trip.new_id()
self.name = name
self._trip_route = weakref.ref(trip_route)
self._calendar = weakref.ref(calendar)
self.stops = []
self._next_block = None
self._previous_block = None
# add us
Trip.trips.append(self)