当前位置: 首页>>代码示例>>Python>>正文


Python Unit.get_by_kode方法代码示例

本文整理汇总了Python中unit.Unit.get_by_kode方法的典型用法代码示例。如果您正苦于以下问题:Python Unit.get_by_kode方法的具体用法?Python Unit.get_by_kode怎么用?Python Unit.get_by_kode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unit.Unit的用法示例。


在下文中一共展示了Unit.get_by_kode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_data

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import get_by_kode [as 别名]
  def import_data(cls):
    filenm ='kegiatan_sub.csv'
    with open(filenm, 'rb') as csvfile:
      reader = csv.DictReader(csvfile, delimiter=';', quotechar='"')
      i = 0
      for row in reader:
        i += 1
        if i/100 ==i/100.0:
          print i
        #print row
        tahun = row['tahun'].strip()
        kegiatan_id = Kegiatan.get_by_kode(row['kegiatan'].strip()).id
        unit_id = Unit.get_by_kode(row['unit'].strip()).id
        no_urut = row['no_urut'].strip()
        data = cls.get_by_kode(tahun, kegiatan_id, unit_id, no_urut)
        if not data:
          data=cls()
          data.kegiatan_id = kegiatan_id
          data.unit_id = unit_id
          data.no_urut = no_urut
          data.created = datetime.now()
          data.create_uid = 1
          data.tahun_id = row['tahun'] 
          #data.level_id = data.kode.count('.')+1
          #data.parent_id = DBSession.query(Rekening.id).filter(Rekening.kode==data.kode[:data.kode.rfind('.')]).scalar()
          data.disabled = 0
          #data.defsign = 1
          #data.program_id=Program.get_by_kode(''.join([row['urusankd'].strip(),'.',row['programkd'].strip()])).id
        data.kode = row['kegiatan']
        data.nama = row['nama'].strip()
        data.amt_lalu = 0
        data.amt_yad  = 0
        data.ppa      = 0
        data.ppas     = 0
        data.ppa_rev  = 0
        data.ppas_rev = 0
        data.pending  = 0
        data.tahunke  = 0
        data.h0yl     = 0
        data.p0yl     = 0
        data.r0yl     = 0
        data.h1yl     = 0
        data.p1yl     = 0
        data.r1yl     = 0
        data.h2yl     = 0
        data.p2yl     = 0
        data.r2yl     = 0

        DBSession.add(data)
    DBSession.flush()
    DBSession.commit()
开发者ID:aagusti,项目名称:o-sipkd,代码行数:53,代码来源:kegiatan_sub.py

示例2: import_data

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import get_by_kode [as 别名]
 def import_data(cls):
   filenm ='kegiatan_item.csv'
   with open(filenm, 'rb') as csvfile:
     reader = csv.DictReader(csvfile, delimiter=';', quotechar='"')
     i = 0
     for row in reader:
       i += 1
       if i<48000:
           continue
       if i/100 == i/100.0:
         print i
       if i/1000 == i/1000.0:
         DBSession.commit()
         print 'Commit %s' % i
       tahun = row['tahun'].strip()
       kegiatan_id = Kegiatan.get_by_kode(row['kegiatan'].strip()).id
       unit_id = Unit.get_by_kode(row['unit'].strip()).id
       no_urut = row['no_urut'].strip()
       tahun = row['tahun']
       kegiatan_sub_id = KegiatanSub.get_by_kode(tahun,kegiatan_id, unit_id, no_urut).id
       rekening_id= Rekening.get_by_kode(row['rekening'].strip(),datetime.now().year).id
       no_urut2 = row['no_urut2'].strip()
       data = cls.get_by_kode(kegiatan_sub_id, rekening_id, no_urut2)
       if not data:
         data=cls()
         data.kegiatan_sub_id = kegiatan_sub_id
         data.rekening_id     = rekening_id
         data.no_urut         = row['no_urut2']
         data.created = datetime.now()
         data.create_uid = 1
         data.disabled = 0
         
       data.kode            = row['kode'][:32] or None
       data.vol_1_1         = row['vol_1_1'].replace(',','.') or 0
       data.sat_1_1         = row['sat_1_1'] or None
       data.vol_1_2         = row['vol_1_2'].replace(',','.') or 0
       data.sat_1_2         = row['sat_1_2'] or None
       data.hsat_1          = row['hsat_1'] and int(float(row['hsat_1'].replace(',','.'))) or 0
       data.vol_2_1         = row['vol_1_1'].replace(',','.') or 0
       data.sat_2_1         = row['sat_1_1'] or None
       data.vol_2_2         = row['vol_1_2'].replace(',','.') or 0
       data.sat_2_2         = row['sat_1_2'] or None
       data.hsat_2          = row['hsat_1'] and int(float(row['hsat_1'].replace(',','.'))) or 0
       data.vol_3_1         = row['vol_3_1'].replace(',','.') or 0
       data.sat_3_1         = row['sat_3_1'] or None
       data.vol_3_2         = row['vol_3_2'].replace(',','.') or 0
       data.sat_3_2         = row['sat_3_2'] or None
       data.hsat_3          = row['hsat_3'] and int(float(row['hsat_3'].replace(',','.'))) or 0
       data.vol_4_1         = row['vol_3_1'].replace(',','.') or 0
       data.sat_4_1         = row['sat_3_1'] or None
       data.vol_4_2         = row['vol_3_2'].replace(',','.') or 0
       data.sat_4_2         = row['sat_3_2'] or None
       data.hsat_4          = row['hsat_3'] and int(float(row['hsat_3'].replace(',','.'))) or 0
       data.pelaksana       = row['pelaksana'][:25] or None
       data.mulai           = row['mulai'] and datetime.strptime(row['mulai'],'%d/%m/%Y %H:%M:%S') or None
       data.selesai         = row['selesai'] and datetime.strptime(row['selesai'],'%d/%m/%Y %H:%M:%S') or None
       data.bln01           = row['bln01'] and int(float(row['bln01'].replace(',','.'))) or 0
       data.bln02           = row['bln02'] and int(float(row['bln02'].replace(',','.'))) or 0
       data.bln03           = row['bln03'] and int(float(row['bln03'].replace(',','.'))) or 0
       data.bln04           = row['bln04'] and int(float(row['bln04'].replace(',','.'))) or 0
       data.bln05           = row['bln05'] and int(float(row['bln05'].replace(',','.'))) or 0
       data.bln06           = row['bln06'] and int(float(row['bln06'].replace(',','.'))) or 0
       data.bln07           = row['bln07'] and int(float(row['bln07'].replace(',','.'))) or 0
       data.bln08           = row['bln08'] and int(float(row['bln08'].replace(',','.'))) or 0
       data.bln09           = row['bln09'] and int(float(row['bln09'].replace(',','.'))) or 0
       data.bln10           = row['bln10'] and int(float(row['bln10'].replace(',','.'))) or 0
       data.bln11           = row['bln11'] and int(float(row['bln11'].replace(',','.'))) or 0
       data.bln12           = row['bln12'] and int(float(row['bln12'].replace(',','.'))) or 0
       data.is_summary      = row['is_summary']== -1 and 1 or 0
       data.is_apbd         = row['is_apbd'] == -1 and 1 or 0
       data.keterangan      = row['ket'] or None
       data.nama            = row['nama'].strip()
       DBSession.add(data)
       DBSession.flush()
   DBSession.commit()
开发者ID:aagusti,项目名称:o-sipkd,代码行数:77,代码来源:kegiatan_item.py


注:本文中的unit.Unit.get_by_kode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。