本文整理汇总了Python中utility.Utility类的典型用法代码示例。如果您正苦于以下问题:Python Utility类的具体用法?Python Utility怎么用?Python Utility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utility类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _parse_dir
def _parse_dir(self):
dir_name = Utility.get_dir_name(self.current_path)
file_name = Utility.get_base_name(self.current_path)
# get files with extension stored in ext
file_list = []
for ext in self.extension_list:
file_list += glob.glob1(dir_name, ext)
# sort list
file_list = [f for f in file_list]
file_list.sort()
# current file index list
current_index = file_list.index(file_name)
# find the next file path
if current_index + 1 < len(file_list):
self._next_path = \
dir_name + '/' + file_list[current_index + 1]
else:
self._next_path = None
# find the previous file path
if current_index > 0:
self._previous_path = \
dir_name + '/' + file_list[current_index - 1]
else:
self._previous_path = None
return file_list
开发者ID:gitter-badger,项目名称:pynocchio-comic-reader,代码行数:32,代码来源:path_file_filter.py
示例2: simpanItemMutasi
def simpanItemMutasi(reqData):
requtil = Utility(reqData=reqData);
id = requtil.nvlGet('id', 0)
idBrg = requtil.nvlGet('barang_id', 0)
pbl = None
if id == 0:
pbl = initMutasi(reqData)
else:
pbls = models.Mutasi.objects.filter(id__exact=id)
if len(pbls):
pbl = pbls[0]
#prepare barang
brg = None
brgs = models.Barang.objects.filter(id__exact=idBrg)
if len(brgs):
brg = brgs[0]
else:
raise StandardError('Barang ini tidak ditemukan')
ipbl = models.ItemMutasi()
ipbl.barang = brg
ipbl.mutasi = pbl
ipbl.harga = brg.harga
ipbl.jumlah = requtil.nvlGet('barang_qty', 0)
ipbl.save()
return ipbl
开发者ID:tejo-ak,项目名称:warehouse,代码行数:25,代码来源:mutasiMgt.py
示例3: parse_Jobberman
def parse_Jobberman(self, response):
i = CareerItem()
utility = Utility()
i['url'] = response.url
logging.info(response.url)
try:
i['title'] = response.xpath('//div[@class="job-quick-sum"]/h1/text()').extract()[0]
except IndexError:
i['title'] = response.xpath('//div[@class="job-quick-sum"]/h1/text()').extract()
try:
description = response.xpath('//div[@class="job-details-main"]/p[2]/text()').extract()[0]
except IndexError:
description = response.xpath('//div[@class="job-details-main"]/p[2]/text()').extract()
i['description'] = utility.limit_length_of_string(description)#(description[:150] + '...') if len(description) > 150 else description
i['category'] = utility.stringReplace(self.category, '/', ',')
i['location'] = self.location #str(self.location).replace('/', ',')
# try:
# i['location'] = response.xpath('//div[@class="job-details-sidebar"]/p[7]/a/text()').extract()[0]
# except IndexError:
# i['location'] = response.xpath('//div[@class="job-details-sidebar"]/p[7]/a/text()').extract()
# try:
# i['category'] = str(response.xpath('//div[@class="job-details-sidebar"]/p[9]/a/text()').extract()[0]).replace('/', ',')
# except IndexError:
# i['category'] = str(response.xpath('//div[@class="job-details-sidebar"]/p[9]/a/text()').extract()).replace('/', ',')Onye
i['sponsor'] = 'jobberman.com'
#log.msg(i)
yield i
开发者ID:samsoft00,项目名称:careervacancy,代码行数:33,代码来源:jobberman_crawler.py
示例4: stop_loop
def stop_loop():
now = time.time()
if now < deadline and (io_loop._callbacks or io_loop._timeouts):
io_loop.add_timeout(now + 1, stop_loop)
else:
io_loop.stop()
Utility.print_msg ('\033[93m'+ 'shutdown' + '\033[0m', True, 'done')
开发者ID:thouis,项目名称:icon,代码行数:7,代码来源:server.py
示例5: addTask
def addTask(projectId, taskId, taskType):
tasks = Settings.getTasks(projectId, taskType)
if taskId in tasks:
return
tasks.append( taskId )
path = "%s/%s.%s.json"%(PROJECTS_PATH, projectId, taskType)
Utility.saveJson( path, tasks )
开发者ID:Rhoana,项目名称:icon,代码行数:7,代码来源:settings.py
示例6: main_handler
def main_handler():
response.content_type = 'application/json'
return {
'status': 'OK',
'detail': 'Nothing to show on this page, try http://%s:%s/login'
% (Utility.ins().hostname(), Utility.ins().port())
}
开发者ID:linfan,项目名称:google-calendar-wrapper,代码行数:7,代码来源:root.py
示例7: load
def load(self, filename, initial_page=0):
image_extensions = ['.bmp', '.jpg', '.jpeg', '.gif', '.png', '.pbm',
'.pgm', '.ppm', '.tiff', '.xbm', '.xpm', '.webp']
loader = LoaderFactory.create_loader(
Utility.get_file_extension(filename), set(image_extensions))
loader.progress.connect(self.load_progressbar_value)
try:
loader.load(filename)
except NoDataFindException as excp:
# Caso nao exista nenhuma imagem, carregamos a imagem indicando
# erro
from page import Page
print excp.message
q_file = QtCore.QFile(":/icons/notCover.png")
q_file.open(QtCore.QIODevice.ReadOnly)
loader.data.append(Page(q_file.readAll(), 'exit_red_1.png', 0))
self.comic = Comic(Utility.get_base_name(filename),
Utility.get_dir_name(filename), initial_page)
self.comic.pages = loader.data
self.current_directory = Utility.get_dir_name(filename)
self.path_file_filter.parse(filename)
开发者ID:gitter-badger,项目名称:pynocchio-comic-reader,代码行数:27,代码来源:main_window_model.py
示例8: index
def index(request):
util = Utility(post=request.POST, get=request.GET)
c = util.nvlGet('c');
if c is not None:
if 'formtutorial' == c:
return render_to_response('inventory/form_tutorial.html')
if 'local' == c:
t = loader.get_template('portal_ivtamd.html')
djProd = '''http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/'''
djProdExt = '''.js'''
djDev = '''/static/dojolib/'''
djDevExt = '''.js'''
d = {"dj": djDev, 'djExt': djProdExt}
return HttpResponse(t.render(Context(d)))
if 'home' == c:
return render_to_response('inventory/web.html')
if 'pabean' == c:
return render_to_response('inventory/dokumen_css.html')
else:
#t = loader.get_template('portal_ivt.html')
t = loader.get_template('portal_ivtamd.html')
# t = loader.get_template('portal_inventory.html') // the old system
#djProd = '''http://ajax.googleapis.com/ajax/libs/dojo/1.6/'''
djProd = '''http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/'''
djProdExt = '''.js'''
djDev = '''/static/dojolib/'''
djDevExt = '''.js'''
d = {"dj": djProd, 'djExt': djProdExt}
return HttpResponse(t.render(Context(d)))
开发者ID:tejo-ak,项目名称:warehouse,代码行数:29,代码来源:views.py
示例9: build_alert
def build_alert(self, alert_id, alert_message, location=None):
"""Build the actual alert and returns it, formatted.
DEPRECATION NOTICE: The 'alert_id' field has been introduced for
better readability. It's currently set to be the same as 'id'.
At some point in the future, the 'id' field will be removed.
Args:
alert_id (int): The ID of the alert you want to build
alert_message (str): The message to be embedded in the alert.
Returns:
tuple: Position 0 contains the string 'sitch_alert'. Position 1
contains the alert and metadata.
"""
if location is None:
print("AlertManager: No geo for alarm: %s" % str(alert_message))
location = {"type": "Point", "coordinates": [0, 0]}
elif Utility.validate_geojson(location) is False:
print("AlertManager: Invalid geojson %s for: %s" % (location,
alert_message))
location = {"type": "Point", "coordinates": [0, 0]}
lat = location["coordinates"][1]
lon = location["coordinates"][0]
gmaps_url = Utility.create_gmaps_link(lat, lon)
message = Utility.generate_base_event()
message["alert_id"] = alert_id
message["id"] = alert_id
message["alert_type"] = self.get_alert_type(alert_id)
message["event_type"] = "sitch_alert"
message["details"] = ("%s %s" % (alert_message, gmaps_url))
message["location"] = location
retval = ("sitch_alert", message)
return retval
开发者ID:sitch-io,项目名称:sensor,代码行数:34,代码来源:alert_manager.py
示例10: addPredictionTask
def addPredictionTask(projectId, taskId):
print 'addPredictionTask....'
path = "%s/%s.%s.json"%(PROJECTS_PATH, projectId, PREDICT_TASK_TYPE)
Utility.lock(path)
Settings.reconcilePredictionTasks( projectId )
Settings.addTask(projectId, taskId, PREDICT_TASK_TYPE)
Utility.unlock(path)
开发者ID:Rhoana,项目名称:icon,代码行数:7,代码来源:settings.py
示例11: removeTask
def removeTask(projectId, taskId, taskType):
tasks = Settings.getTasks(projectId, taskType)
if taskId in tasks:
tasks.remove( taskId)
path = "%s/%s.%s.json"%(PROJECTS_PATH, projectId, taskType)
if not Utility.isLocked( path ):
Utility.saveJson( path, tasks )
开发者ID:Rhoana,项目名称:icon,代码行数:7,代码来源:settings.py
示例12: close_file
def close_file(self, left_hemi_file, right_hemi_file, left_curvature_output_file, right_curvature_output_file):
'''
'''
m = numpy.ctypeslib.as_array(self.__matrix.get_obj())
m = m.reshape(self.__shape)
#here
lh_vertices, lh_faces = nibabel.freesurfer.read_geometry( left_hemi_file )
rh_vertices, rh_faces = nibabel.freesurfer.read_geometry( right_hemi_file )
sum_vector = numpy.sum( m, axis=0 )
import sys, os
sys.path.append(os.path.join( os.path.dirname( __file__ ),'../'))
from utility import Utility
# write curvature files
Utility.write_freesurfer_curvature( left_curvature_output_file, sum_vector[0:len( lh_vertices )] )
Utility.write_freesurfer_curvature( right_curvature_output_file, sum_vector[len( lh_vertices ):] ) # here we start with the offset
# end here
print 'crv written!!! FTW!'
numpy.save( self.__matrix_file, m)
print 'stored matrix'
开发者ID:FNNDSC,项目名称:F3000,代码行数:26,代码来源:fy_super_surface_map_action.py
示例13: lookupBdi
def lookupBdi(katakunci, inventory_id, id, max):
requtil = Utility()
if max is None:
max = 40;
pasiens = []
if katakunci is not None and '' != katakunci and id is None:
print 'katakunci'
print max
pasiens = models.BarangDiInventory.objects.filter(
Q(barang__nama__icontains=katakunci) | Q(barang__merk__icontains=katakunci) |
Q(barang__kode__icontains=katakunci, inventori__id__exact=inventory_id))[
:max]
elif id is not None:
print 'id'
pasiens = models.BarangDiInventory.objects.filter(barang__id__exact=id)
print 'query from id'
#lookup specific id, to set id value
else:
print 'other'
print id
print katakunci
pasiens = models.BarangDiInventory.objects.filter(inventory__id__exact=inventory_id)[:max]
jpasiens = [];
for bdi in pasiens:
jpasien = requtil.modelToDicts([bdi.barang])
jpasiens.append(jpasien)
return jpasiens;
开发者ID:tejo-ak,项目名称:warehouse,代码行数:27,代码来源:barangMgt.py
示例14: lookupBarang
def lookupBarang(katakunci, id, max):
requtil = Utility()
if max is None:
max = 40;
pasiens = []
if katakunci is not None and '' != katakunci and id is None:
print 'katakunci'
print max
pasiens = models.Barang.objects.filter(
Q(nama__icontains=katakunci) | Q(merk__icontains=katakunci) | Q(kode__icontains=katakunci))[
:max]
elif id is not None:
print 'id'
pasiens = models.Barang.objects.filter(id__exact=id)
print 'query from id'
#lookup specific id, to set id value
else:
print 'other'
print id
print katakunci
pasiens = models.Barang.objects.all()[:max]
jpasiens = [];
for pasien in pasiens:
jpasien = requtil.modelToDicts([pasien])
jpasiens.append(jpasien)
return jpasiens;
开发者ID:tejo-ak,项目名称:warehouse,代码行数:26,代码来源:barangMgt.py
示例15: getSupplierSider
def getSupplierSider(reqData):
requtil = Utility(reqData=reqData)
pas = models.Supplier.objects.filter(id__exact=requtil.nvlGet('id'))
if pas[0] is not None:
id = pas[0].id
jpas = requtil.modelToDicts([pas[0]])
html = render_to_string('inventory/form_supplier_sider.html', jpas)
return html
开发者ID:tejo-ak,项目名称:warehouse,代码行数:8,代码来源:supplierMgt.py
示例16: initKonversi
def initKonversi(reqData):
requtil = Utility(reqData=reqData);
_apu = appUtil()
#prepare inventory
pbl = models.Konversi()
pbl.nomor = ('00000000000000%s' % (_apu.getIncrement(5)))[-6:]
pbl.inventory = getInvById(requtil.nvlGet('inventory_id'))
pbl.save()
return pbl
开发者ID:tejo-ak,项目名称:warehouse,代码行数:9,代码来源:konversiMgt.py
示例17: initPengeluaranPabean
def initPengeluaranPabean(reqData):
requtil = Utility(reqData=reqData);
_apu = appUtil()
#prepare inventory
pbl = models.DokumenPabean()
pbl = requtil.bindRequestModel(pbl)
pbl.nomor = ('00000000000000%s' % (_apu.getIncrement(7)))[-6:]
pbl.inventory = models.Inventory.objects.get(id__exact=requtil.nvlGet('inventory_id'))
pbl.save()
return pbl
开发者ID:tejo-ak,项目名称:warehouse,代码行数:10,代码来源:transaksiPabeanMgt.py
示例18: getBarangSider
def getBarangSider(reqData):
requtil = Utility(reqData=reqData)
pas = models.Barang.objects.filter(id__exact=requtil.nvlGet('id'))
if pas[0] is not None:
id = pas[0].id
jpas = requtil.modelToDicts([pas[0]])
urlss = "000000%s.jpg" % (id)
jpas['url'] = urlss[-10:]
html = render_to_string('inventory/form_barang_sider.html', jpas)
return html
开发者ID:tejo-ak,项目名称:warehouse,代码行数:10,代码来源:barangMgt.py
示例19: reportTrainingStats
def reportTrainingStats(self, elapsedTime, batchIndex, valLoss, trainCost, mode=0):
DB.storeTrainingStats( self.id, valLoss, trainCost, mode=mode)
msg = '(%0.1f) %i %f%%'%\
(
elapsedTime,
batchIndex,
valLoss
)
status = '[%f]'%(trainCost)
Utility.report_status( msg, status )
开发者ID:Rhoana,项目名称:icon,代码行数:10,代码来源:oldunet2.py
示例20: initMutasi
def initMutasi(reqData):
requtil = Utility(reqData=reqData);
_apu = appUtil()
#prepare inventory
pbl = models.Mutasi()
pbl.nomor = ('00000000000000%s' % (_apu.getIncrement(4)))[-6:]
pbl.asal = getInvById(requtil.nvlGet('inventory_asal_id'))
pbl.tujuan = getInvById(requtil.nvlGet('inventory_tujuan_id'))
pbl.save()
return pbl
开发者ID:tejo-ak,项目名称:warehouse,代码行数:10,代码来源:mutasiMgt.py
注:本文中的utility.Utility类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论