• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.data_dir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.data_dir函数的典型用法代码示例。如果您正苦于以下问题:Python data_dir函数的具体用法?Python data_dir怎么用?Python data_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _checkValidationFile

    def _checkValidationFile(self,path):
        result = False
        
        #copy the file and open it
        self.xbmc_vfs.put(path + "xbmcbackup.val",xbmc.translatePath(utils.data_dir() + "xbmcbackup_restore.val"))

        vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup_restore.val"),'r')
        jsonString = vFile.read()
        vFile.close()

        #delete after checking
        xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "xbmcbackup_restore.val"))

        try:
            json_dict = json.loads(jsonString)

            if(xbmc.getInfoLabel('System.BuildVersion') == json_dict['xbmc_version']):
                result = True
            else:
                result = xbmcgui.Dialog().yesno(utils.getString(30085),utils.getString(30086),utils.getString(30044))
                
        except ValueError:
            #may fail on older archives
            result = True

        return result
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:26,代码来源:backup.py


示例2: _readCronFile

    def _readCronFile(self):
        if(not os.path.exists(xbmc.translatePath(utils.data_dir()))):
            os.makedirs(xbmc.translatePath(utils.data_dir()))

        adv_jobs = []
        try:
            doc = xml.dom.minidom.parse(xbmc.translatePath(utils.data_dir() + "cron.xml"))
            
            for node in doc.getElementsByTagName("job"):
                tempJob = CronJob()
                tempJob.name = str(node.getAttribute("name"))
                tempJob.command = str(node.getAttribute("command"))
                tempJob.expression = str(node.getAttribute("expression"))
                tempJob.show_notification = str(node.getAttribute("show_notification"))
                tempJob.id = len(adv_jobs)
                
                utils.log(tempJob.name + " " + tempJob.expression + " loaded")
                adv_jobs.append(tempJob)

        except IOError:
            #the file doesn't exist, return empty array
            doc = xml.dom.minidom.Document()
            rootNode = doc.createElement("cron")
            doc.appendChild(rootNode)
            #write the file
            f = open(xbmc.translatePath(utils.data_dir() + "cron.xml"),"w")
            doc.writexml(f,"   ")
            f.close()
            

        return adv_jobs
开发者ID:donintend0,项目名称:cronxbmc,代码行数:31,代码来源:cron.py


示例3: setup

    def setup(self):
        #create authorization helper and load default settings
        gauth = GoogleAuth(xbmc.validatePath(xbmc.translatePath(utils.addon_dir() + '/resources/lib/pydrive/settings.yaml')))
        gauth.LoadClientConfigSettings()
        
        #check if this user is already authorized
        if(not xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "google_drive.dat"))):
            settings = {"client_id":self.CLIENT_ID,'client_secret':self.CLIENT_SECRET}
    
            drive_url = gauth.GetAuthUrl(settings)
    
            utils.log("Google Drive Authorize URL: " + drive_url)

            code = xbmcgui.Dialog().input('Google Drive Validation Code','Input the Validation code after authorizing this app')

            gauth.Auth(code)
            gauth.SaveCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))
        else:
            gauth.LoadCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))
    
        #create the drive object
        self.drive = GoogleDrive(gauth)
        
        #make sure we have the folder we need
        xbmc_folder = self._getGoogleFile(self.root_path)
        print xbmc_folder
        if(xbmc_folder == None):
            self.mkdir(self.root_path)
开发者ID:elephunk84,项目名称:Kodi-Addons,代码行数:28,代码来源:vfs.py


示例4: get_output_path

def get_output_path(collection, package_name, options):
    # Where to store the document files?

    # The path will depend a bit on the collection.
    if collection == "BILLS":
        # Store with the other bill data ([congress]/bills/[billtype]/[billtype][billnumber]).
        bill_and_ver = get_bill_id_for_package(package_name, with_version=False, restrict_to_congress=options.get("congress"))
        if not bill_and_ver:
            return None  # congress number does not match options["congress"]
        from bills import output_for_bill
        bill_id, version_code = bill_and_ver
        return output_for_bill(bill_id, "text-versions/" + version_code, is_data_dot=False)

    elif collection == "CRPT":
        # Store committee reports in [congress]/crpt/[reporttype].
        m = re.match(r"(\d+)([hse]rpt)(\d+)$", package_name)
        if not m:
            raise ValueError(package_name)
        congress, report_type, report_number = m.groups()
        if options.get("congress") and congress != options.get("congress"):
            return None  # congress number does not match options["congress"]
        return "%s/%s/%s/%s/%s" % (utils.data_dir(), congress, collection.lower(), report_type, report_type + report_number)
    
    else:
        # Store in govinfo/COLLECTION/PKGNAME.
        path = "%s/govinfo/%s/%s" % (utils.data_dir(), collection, package_name)
        return path
开发者ID:d0tN3t,项目名称:congress,代码行数:27,代码来源:govinfo.py


示例5: _createValidationFile

    def _createValidationFile(self):
        vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'w')
        vFile.write(json.dumps({"name":"XBMC Backup Validation File","xbmc_version":xbmc.getInfoLabel('System.BuildVersion')}))
        vFile.write("")
        vFile.close()

        self.remote_vfs.put(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),self.remote_vfs.root_path + "xbmcbackup.val")
开发者ID:liljayballer1010,项目名称:xbmcbackup,代码行数:7,代码来源:backup.py


示例6: __init__

        def __init__(self):                
                self.dataBasePath = os.path.join(xbmc.translatePath(utils.data_dir()), 'History.db')
                #use scripts home for reading SQL files
                self.sqlDir = os.path.join(xbmc.translatePath(utils.addon_dir()), 'resources', 'database')

                #quick check to make sure data_dir exists
                if(not xbmcvfs.exists(xbmc.translatePath(utils.data_dir()))):
                        xbmcvfs.mkdir(xbmc.translatePath(utils.data_dir()))
开发者ID:robweber,项目名称:service.history,代码行数:8,代码来源:database.py


示例7: getToken

    def getToken(self):
        #get tokens, if they exist
        if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "tokens.txt"))):
            token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"))
            key,secret = token_file.read().split('|')
            token_file.close()

            return [key,secret]
        else:
            return ["",""]
开发者ID:nspierbundel,项目名称:OpenELEC.tv,代码行数:10,代码来源:vfs.py


示例8: run

def run(options):
  pages = []
  if options.get('page'):
    pages = [int(options.get('page'))]
  elif options.get('pages'):
    begin = int(options.get('begin', 1))
    pages = list(range(begin, int(options.get('pages'))+1))
  else:
    pages = [1]

  per_page = int(options.get('per_page', 200))

  limit = options.get('limit')
  count = 0

  print("Processing pages %i through %i." % (pages[0], pages[-1]))

  # go through each requested page
  for page in pages:
    print("[%i] Loading page." % page)
    page_path = "%s/state/pages/%i/%i.json" % (utils.data_dir(), per_page, page)
    page_data = json.load(open(page_path))
    for result in page_data['Results']:
      do_document(result, page, options)
      count += 1
      if limit and (count >= int(limit)):
        break
    if limit and (count >= int(limit)):
      break

  print("All done! Processed %i documents." % count)
开发者ID:VikashLoomba,项目名称:foia,代码行数:31,代码来源:state-data.py


示例9: run

def run(options):
  # Load the committee metadata from the congress-legislators repository and make a
  # mapping from thomas_id and house_id to the committee dict. For each committee,
  # replace the subcommittees list with a dict from thomas_id to the subcommittee.
  utils.require_congress_legislators_repo()
  committees = { }
  for c in utils.yaml_load("congress-legislators/committees-current.yaml"):
    committees[c["thomas_id"]] = c
    if "house_committee_id" in c: committees[c["house_committee_id"] + "00"] = c
    c["subcommittees"] = dict((s["thomas_id"], s) for s in c.get("subcommittees", []))

  for chamber in ("house", "senate"):
    # Load any existing meetings file so we can recycle GUIDs generated for Senate meetings.
    existing_meetings = []
    output_file = utils.data_dir() + "/committee_meetings_%s.json" % chamber
    if os.path.exists(output_file):
      existing_meetings = json.load(open(output_file))

    # Scrape for meeting info.
    if chamber == "senate":
      meetings = fetch_senate_committee_meetings(existing_meetings, committees, options)
    else:
      meetings = fetch_house_committee_meetings(existing_meetings, committees, options)

    # Write out.
    utils.write(json.dumps(meetings, sort_keys=True, indent=2, default=utils.format_datetime),
      output_file)
开发者ID:GPHemsley,项目名称:congress,代码行数:27,代码来源:committee_meetings.py


示例10: _writeCronFile

    def _writeCronFile(self):
        
        #write the cron file in full
        try:
            doc = xml.dom.minidom.Document()
            rootNode = doc.createElement("cron")
            doc.appendChild(rootNode)
            
            for aJob in self.jobs:
                
                #create the child
                newChild = doc.createElement("job")
                newChild.setAttribute("name",aJob.name)
                newChild.setAttribute("expression",aJob.expression)
                newChild.setAttribute("command",aJob.command)
                newChild.setAttribute("show_notification",aJob.show_notification)

                rootNode.appendChild(newChild)

            #write the file
            f = open(xbmc.translatePath(utils.data_dir() + "cron.xml"),"w")
            doc.writexml(f,"   ")
            f.close()
                                        
        except IOError:
            self.log("error writing cron file")
开发者ID:donintend0,项目名称:cronxbmc,代码行数:26,代码来源:cron.py


示例11: _readHosts

    def _readHosts(self):
        data_dir = utils.data_dir()

        if(not xbmcvfs.exists(data_dir)):
            xbmcvfs.mkdir(data_dir)

        try:
            doc = xml.dom.minidom.parse(xbmc.translatePath(data_dir + "hosts.xml"))

            for node in doc.getElementsByTagName("host"):
                self.hosts.append(XbmcHost(str(node.getAttribute("name")),str(node.getAttribute("address")),int(node.getAttribute("port"))))

            #sort the lists
            self._sort()
            
        except IOError:
            #the file doesn't exist, create it
            doc = xml.dom.minidom.Document()
            rootNode = doc.createElement("hosts")
            doc.appendChild(rootNode)

            #write the file
            f = open(xbmc.translatePath(data_dir + "hosts.xml"),'w')
            doc.writexml(f,"   ")
            f.close()
开发者ID:bstrdsmkr,项目名称:script.sendto,代码行数:25,代码来源:hostmanager.py


示例12: save_file

def save_file(url, event_id):
    # not saving xml but I cold be convinced otherwise
    if ".xml" in url:
        return False

    r = requests.get(url, stream=True)

    if r.status_code == requests.codes.ok:
        # find or create directory
        folder = str(int(event_id) / 100)
        output_dir = utils.data_dir() + "/committee/meetings/house/%s/%s" % (folder, event_id)
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
        # get file name
        splinter = url.split("/")
        name = splinter[-1]
        file_name = "%s/%s" % (output_dir, name)
        # try to save

        try:
            logging.info("saved " + url + " to " + file_name)
            with open(file_name, "wb") as document_file:
                document_file.write(r.content)
            if ".pdf" in file_name:
                text_doc = text_from_pdf(file_name)
            return True
        except:
            print "Failed to save- %s" % (url)
            return False
    else:
        logging.info("failed to fetch: " + url)
        return False
开发者ID:unitedstates,项目名称:congress,代码行数:32,代码来源:committee_meetings.py


示例13: save_documents

def save_documents(package, event_id):
    uploaded_documents = []

    # find/create directory
    folder = str(int(event_id) / 100)
    output_dir = utils.data_dir() + "/committee/meetings/house/%s/%s" % (folder, event_id)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    # loop through package and save documents
    for name in package.namelist():
        # for documents that are not xml
        if ".xml" not in name:
            try:
                bytes = package.read(name)
            except:
                print "Did not save to disk: file %s" % (name)
                continue
            file_name = "%s/%s" % (output_dir, name)

            # save document
            logging.info("saved " + file_name)
            with open(file_name, "wb") as document_file:
                document_file.write(bytes)
            # try to make a text version
            text_doc = text_from_pdf(file_name)
            if text_doc != None:
                uploaded_documents.append(text_doc)
            uploaded_documents.append(name)

    return uploaded_documents
开发者ID:unitedstates,项目名称:congress,代码行数:31,代码来源:committee_meetings.py


示例14: write_report

def write_report(report):
  data_path = "%s/%s/%s/report.json" % (report['inspector'], report['year'], report['report_id'])
  utils.write(
    utils.json_for(report),
    "%s/%s" % (utils.data_dir(), data_path)
  )
  return data_path
开发者ID:MRumsey,项目名称:inspectors-general,代码行数:7,代码来源:inspector.py


示例15: _writeHosts

    def _writeHosts(self):
        data_dir = utils.data_dir()

        try:
            doc = xml.dom.minidom.Document()
            rootNode = doc.createElement("hosts")

            #create the child
            for aHost in self.hosts:
                newChild = doc.createElement("host")
                newChild.setAttribute("name",str(aHost.name))
                newChild.setAttribute("address",str(aHost.address))
                newChild.setAttribute("port",str(aHost.port))
                newChild.setAttribute("user",str(aHost.user))
                newChild.setAttribute("password",str(aHost.password))
                rootNode.appendChild(newChild)

            doc.appendChild(rootNode)
            #write the file
            f = open(xbmc.translatePath(data_dir + "hosts.xml"),'w')
            doc.writexml(f,"   ")
            f.close()
            

        except IOError:
            utils.log("Error writing hosts file")
开发者ID:jasherai,项目名称:script.sendto,代码行数:26,代码来源:hostmanager.py


示例16: download_report

def download_report(report):
  report_path = "%s/%s/%s/report.%s" % (report['inspector'], report['year'], report['report_id'], report['file_type'])
  binary = (report['file_type'] == 'pdf')

  utils.download(
    report['url'],
    "%s/%s" % (utils.data_dir(), report_path),
    {'binary': binary}
  )
  return report_path
开发者ID:MRumsey,项目名称:inspectors-general,代码行数:10,代码来源:inspector.py


示例17: _refreshJobs

 def _refreshJobs(self):
     
     #check if we should read in a new files list
     stat_file = xbmcvfs.Stat(xbmc.translatePath(utils.data_dir() + "cron.xml"))
     
     if(stat_file.st_mtime() > self.last_read):
         utils.log("File update, loading new jobs")
         #update the file
         self.jobs = self._readCronFile();
         self.last_read = time.time()
开发者ID:donintend0,项目名称:cronxbmc,代码行数:10,代码来源:cron.py


示例18: output_for_vote

def output_for_vote(vote_id, format):
    vote_chamber, vote_number, vote_congress, vote_session_year = utils.split_vote_id(vote_id)
    return "%s/%s/votes/%s/%s%s/%s" % (
        utils.data_dir(),
        vote_congress,
        vote_session_year,
        vote_chamber,
        vote_number,
        "data.%s" % format,
    )
开发者ID:milimetric,项目名称:congress,代码行数:10,代码来源:vote_info.py


示例19: run

def run(options):
  # accepts yyyymmdd format
  for_the_week = get_monday_of_week(options.get('week_of', None))

  logging.warn('Scraping upcoming bills from docs.house.gov/floor for the week of %s.\n' % for_the_week)
  house_floor = fetch_floor_week(for_the_week, options)

  output_file = "%s/upcoming_house_floor/%s.json" % (utils.data_dir(), for_the_week)
  output = json.dumps(house_floor, sort_keys=True, indent=2, default=utils.format_datetime)
  utils.write(output, output_file)

  logging.warn("\nFound %i bills for the week of %s, written to %s" % (len(house_floor['upcoming_bills']), for_the_week, output_file))
开发者ID:GPHemsley,项目名称:congress,代码行数:12,代码来源:upcoming_house_floor.py


示例20: run

def run(options):

  for_the_week = get_monday_week(options.get('for_the_week', None)) #yyyymmdd

  logging.info('Scraping upcoming bills from docs.house.gov/floor for the week %s.' % for_the_week)
  
  # Parse the content into upcoming_bills
  upcoming_bills = fetch_bills_week(for_the_week, options)

  # Write the json to data folder
  output_file = utils.data_dir() + "/upcoming_bills_%s.json" % for_the_week
  utils.write(json.dumps(upcoming_bills, sort_keys=True, indent=2, default=utils.format_datetime), output_file)
开发者ID:datauy,项目名称:congress,代码行数:12,代码来源:upcoming_bills.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.data_iterator函数代码示例发布时间:2022-05-26
下一篇:
Python utils.curl函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap