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

Python resources.Resources类代码示例

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

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



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

示例1: __launch

def __launch(delegate):
   ''' 
   Runs the given (no-argument) delegate method in a 'safe' script environment.
   This environment will take care of all error handling, logging/debug stream,
   and other standard initialization behaviour before delegate() is called, and
   it will take care of cleaning everything up afterwards.
   ''' 
   try:
      # initialize the application resources (import directories, etc)
      Resources.initialize()
      
      # fire up the debug logging system
      log.install(ComicRack.MainWindow)
      
      # install a handler to catch uncaught Winforms exceptions
      def exception_handler(sender, event):
         log.handle_error(event.Exception)
      Application.ThreadException \
         += ThreadExceptionEventHandler(exception_handler)
         
      # fire up the localization/internationalization system
      i18n.install(ComicRack)
      
      # see if we're in a valid environment
      if __validate_environment():
         delegate()
         
   except Exception, ex:
      log.handle_error(ex)
开发者ID:IPyandy,项目名称:comic-vine-scraper,代码行数:29,代码来源:ComicVineScraper.py


示例2: receive_resources

 def receive_resources(self, resources):
     """
     add the resources to the village
     create a new object resources with this values and return it
     """
     max_resources = self.max_resources_storage()
     transfered_resources = Resources(
         food=min(
             resources.food,
             max_resources.food - int(self.resources.food),
             ),
         wood=min(
             resources.wood,
             max_resources.wood - int(self.resources.wood),
             ),
         silex=min(
             resources.silex,
             max_resources.silex - int(self.resources.silex),
             ),
         skin=min(
             resources.skin,
             max_resources.skin - int(self.resources.skin),
             ),
     )
     #need to create a new instance of resources to remember for the report
     transfered_resources.pk = None
     transfered_resources.save()
     self.resources += transfered_resources
     self.resources.save()
     self.plan_next_starvation()
     return transfered_resources
开发者ID:raphael-boucher,项目名称:dolmen,代码行数:31,代码来源:village.py


示例3: create_tribe

    def create_tribe(name, user, carte):
        """
        Initialise une tribe (à utiliser après la création d'un compte)

        """
        tribe = Tribe(name=name, leader=user)
        tribe.save()

        resources_initiales = Resources(
                wood=INIT_TRIBE_RESOURCES['wood'],
                food=INIT_TRIBE_RESOURCES['food'],
                silex=INIT_TRIBE_RESOURCES['silex'],
                skin=INIT_TRIBE_RESOURCES['skin']
                )

        resources_initiales.save()
        village = Village.create_village(tribe, first=True)

        inhabitants = Group.objects.create(
                position=village.position,
                village=village,
                )
        village.inhabitants = inhabitants
        for key in INIT_TRIBE_UNITS:
            new_pile = UnitStack(
                    unit_type=UnitType.objects.get(identifier__iexact=key),
                    group=inhabitants,
                    number=INIT_TRIBE_UNITS[key],
                    )
            new_pile.save()
        village.update_income()

        return tribe
开发者ID:raphael-boucher,项目名称:dolmen,代码行数:33,代码来源:tribe.py


示例4: __init__

   def __init__(self):
      ''' Creates a _PictureBoxPanel.  Call set_image after initialization. '''
      
      # the left and right arrow Image objects
      self.__left_arrow = Resources.createArrowIcon(True, False)
      self.__full_left_arrow = Resources.createArrowIcon(True, True)
      self.__right_arrow = Resources.createArrowIcon(False, False)
      self.__full_right_arrow = Resources.createArrowIcon(False, True)
      
      # the vertical line boundary between the full_left and left arrow's
      # 'clickable columns' and the full_right and right arrow's.
      self.__left_bound = 0;
      self.__right_bound = 0;

      # the image attributes to use for drawing non-alpha blended images      
      self.__hovered_image_atts = None
      
      # the image attributes to use for drawing alpha blended images      
      self.__normal_image_atts = None
      
      # a string indicating whether the mouse is hovered over the full 
      # left ('FL'), left ('L'), right ('R'), or full right ('FR') side of 
      # this panel, or None if the mouse isn't over the panel at all.  
      self.__mouse_hovered_state = None
      
      # our PictureBox object, which we center and stretch as needed 
      self._picbox = None
      
      Panel.__init__(self)
      self.__build_gui()
开发者ID:Blackbird88,项目名称:comic-vine-scraper,代码行数:30,代码来源:comicform.py


示例5: select_oldest

def select_oldest(cloud, args):
    if cloud and args is not None:
        resources = Resources(cloud)
        age_resources = SelectAgeRelatedResources(cloud)
        age_resources.select_old_instances(
            datetime.timedelta(hours=args.old_active),
            datetime.timedelta(hours=args.old_inactive),
            datetime.timedelta(days=args.old_permanent),
            datetime.timedelta(hours=args.old_inerrror)
        )
        old_resources = age_resources.get_selection()
        new_search_prefix = None
        oldest = None
        if 'instances' in old_resources:
            for instance in old_resources['instances']:
                rec = old_resources['instances'][instance]
                if rec is None:
                    continue
                if oldest is None or oldest > rec['created_on']:
                    oldest = rec['created_on']
                    new_search_prefix = rec['name']
                logging.info('Found Old instance [{}] created on [{}] age [{}]'
                             .format(rec['name'],
                                     rec['created_on'],
                                     str(rec['age'])))

        if oldest is not None:
            substring = get_substr_from_name(new_search_prefix)
            resources.select_resources(substring)
        return resources
    return None
开发者ID:sileht,项目名称:shade_janitor,代码行数:31,代码来源:janitor.py


示例6: PlannerFrame

class PlannerFrame(wx.Frame):
      def __init__(self, parent, id=wx.ID_ANY, title="", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE, name = "PlannerFrame"):
            super(PlannerFrame, self).__init__(parent, id, title, pos, size, style, name)
            self._parent = parent
            self._title = title
            self._resources = Resources(_plannerDataDir+_ResourcesFileName)
            self._fundingSources = FundingSources(_plannerDataDir+_FundingSourcesFileName)
            self._allocations = AllocationSet(_plannerDataDir+_Allocations)

# Create MenuBar
            menuBar = wx.MenuBar()

# Create File Menu
            fileMenu = wx.Menu()
            menuExit = fileMenu.Append(wx.ID_EXIT, "E&xit"," Terminate the program")
            menuSave = fileMenu.Append(wx.ID_SAVE, "&Save", "Save Resources and Funding Sources")
            fileMenu.AppendSeparator()


# Create View Menu
            viewMenu = wx.Menu()

            PLN_RESOURCES = wx.NewId()
            PLN_FUNDINGSOURCES = wx.NewId()
            
            menuResources = viewMenu.Append(PLN_RESOURCES, "&Resources", "Bring up Resources Panel")
            menuFundingSources = viewMenu.Append(PLN_FUNDINGSOURCES, "F&unding Sources", "Bring up Funding Sources Panel")

            menuBar.Append(fileMenu, "&File")
            menuBar.Append(viewMenu, "&View")
            
            self.SetMenuBar(menuBar)
            self.CreateStatusBar()

# File Menu Items
            self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
            self.Bind(wx.EVT_MENU, self.OnSave, menuSave)

# View Menu Items            
            self.Bind(wx.EVT_MENU, self.OnResources, menuResources)
            self.Bind(wx.EVT_MENU, self.OnFundingSources, menuFundingSources)
            
            self.Show(True)

      def OnExit(self, e):
            sys.exit()

      def OnSave(self, e):
            self._resources.write()
            print "Resources Saved"
            self._fundingSources.write()
            print "Funding Sources Saved"
            
      def OnResources(self, e):
            self._resourcesWindow = SelectionListbox(self, self._resources)

      def OnFundingSources(self, e):
            self._fundingSourcesWindow = SelectionListbox(self, self._fundingSources)
开发者ID:swiftbw,项目名称:Planner,代码行数:58,代码来源:planner.py


示例7: updateEncryptionLock

    def updateEncryptionLock(self, msgid, encryption=None):
        if encryption is None:
            return

        if encryption == '':
            lock_icon_path = Resources.get('unlocked-darkgray.png')
        else:
            lock_icon_path = Resources.get('locked-green.png' if encryption == 'verified' else 'locked-red.png')
        script = "updateEncryptionLock('%s','%s')" % (msgid, lock_icon_path)
        self.executeJavaScript(script)
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:10,代码来源:ChatViewController.py


示例8: __init__

 def __init__(self, window):
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path("leftpane.js"), "r") as f:
         self.js = f.read()
     self.setFixedWidth(0)
     self.setVisible(False)
     # We don't want plugins for this simple pane
     self.settings().setAttribute(QWebSettings.PluginsEnabled, False)
     self.setUrl(QUrl.fromLocalFile(Resources.get_path("leftpane.html")))
     self.page().currentFrame().addToJavaScriptWindowObject("leftPane", self)
     self.page().currentFrame().evaluateJavaScript(self.js)
开发者ID:aikikode,项目名称:scudcloud,代码行数:12,代码来源:leftpane.py


示例9: word_sim

 def word_sim(self, w1, w2, simtype):
     if (w1, w2) in AlignAndPenalize.word_cache:
         return AlignAndPenalize.word_cache[(w1, w2)]
     # context-free similarity
     if w1 == w2 or Resources.is_num_equivalent(w1, w2) or Resources.is_pronoun_equivalent(w1, w2):
         AlignAndPenalize.word_cache[(w1, w2)] = 1
         AlignAndPenalize.word_cache[(w2, w1)] = 1
         return 1
     sim = self.similarities[simtype].word_sim(w1, w2)
     if sim is None and self.fallback_similarity:
         sim = self.fallback_similarity.word_sim(w1, w2)
     elif sim is None:
         sim = 0.0
     return sim
开发者ID:juditacs,项目名称:semeval,代码行数:14,代码来源:align_and_penalize.py


示例10: __init__

 def __init__(self, parent = None, settings_path = ""):
     super(ScudCloud, self).__init__(parent)
     self.setWindowTitle('ScudCloud')
     self.settings_path = settings_path
     self.notifier = Notifier(Resources.APP_NAME, Resources.get_path('scudcloud.png'))
     self.settings = QSettings(self.settings_path + '/scudcloud.cfg', QSettings.IniFormat)
     self.identifier = self.settings.value("Domain")
     if Unity is not None:
         self.launcher = Unity.LauncherEntry.get_for_desktop_id("scudcloud.desktop")
     else:
         self.launcher = DummyLauncher(self)
     self.webSettings()
     self.leftPane = LeftPane(self)
     self.stackedWidget = QtGui.QStackedWidget()
     centralWidget = QtGui.QWidget(self)
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     layout.addWidget(self.leftPane)
     layout.addWidget(self.stackedWidget)
     centralWidget.setLayout(layout)
     self.setCentralWidget(centralWidget)
     self.startURL = Resources.SIGNIN_URL
     if self.identifier is not None:
         self.startURL = self.domain()
     self.addWrapper(self.startURL)
     self.addMenu()
     self.tray = Systray(self)
     self.systray(ScudCloud.minimized)
     self.installEventFilter(self)
     self.statusBar().showMessage('Loading Slack...')
开发者ID:mynameisfiber,项目名称:scudcloud,代码行数:31,代码来源:scudcloud.py


示例11: set_image

 def set_image(self, image):
    '''
    Sets a new image for this _PictureBoxPanel to display.   If this image is
    None, a default logo will be displayed.  Any previous image that was set
    will have its Dispose() method called before it is discarded.
    '''
    
    if not image:
       image = Resources.createComicVineLogo()
    
    self._ratio = 0;
    if image and float(image.Height):
       self._ratio = float(image.Width) / float(image.Height)
    if not self._ratio:
       self._ratio =1.55
       
    # dispose the old image, if need be
    if self._picbox.Image:
       self._picbox.Image.Dispose()
       
    self._picbox.Image = image
    self.OnResize(None)
    
    # update our mouse cursor
    comicform = self.Parent
    if comicform != None:
       self.Cursor = Cursors.Hand if comicform._can_change_page(True) or \
         comicform._can_change_page(False) else None
开发者ID:Blackbird88,项目名称:comic-vine-scraper,代码行数:28,代码来源:comicform.py


示例12: __init__

    def __init__(self, title, resources=None, other=None):
        self.title = title
        self.parent = None

        if resources is None:
            self.resources = Resources()
        else:
            self.resources = resources

        self.other = other

        self.wid_delete_btn = widgets.Button(description='Delete', margin="8px")
        self.wid_delete_btn._gem_ctx = self

        def yes_cb(model):
            parent = model.parent_get()
            parent.model_del(model)

        def no_cb(model):
            return

        def model_delete_cb(model_delete_cb):
            metys_confirm("Delete '%s' model, confirm it ?" % self.title, yes_cb, no_cb, self)
            return

        self.wid_delete_btn.on_click(model_delete_cb)
        wid_label = widgets.Label(value="Model:")
        self.widget = widgets.VBox(children=[
            self.resources.widget_get(), wid_label, self.wid_delete_btn])
开发者ID:gem,项目名称:oq-mbt,代码行数:29,代码来源:models.py


示例13: __init__

 def __init__(self, parent = None, settings_path = ""):
     super(zcswebapp, self).__init__(parent)
     self.setWindowTitle('zcswebapp')
     self.settings_path = settings_path
     self.notifier = Notifier(Resources.APP_NAME, Resources.get_path('zcswebapp.png'))
     self.settings = QSettings(self.settings_path + '/zcswebapp.cfg', QSettings.IniFormat)
     self.identifier = self.settings.value("Domain")
     if Unity is not None:
         self.launcher = Unity.LauncherEntry.get_for_desktop_id("zcswebapp.desktop")
     else:
         self.launcher = DummyLauncher(self)
     self.webSettings()
     self.leftPane = LeftPane(self)
     webView = Wrapper(self)
     webView.page().networkAccessManager().setCookieJar(self.cookiesjar)
     self.stackedWidget = QtGui.QStackedWidget()
     self.stackedWidget.addWidget(webView)
     centralWidget = QtGui.QWidget(self)
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     layout.addWidget(self.leftPane)
     layout.addWidget(self.stackedWidget)
     centralWidget.setLayout(layout)
     self.setCentralWidget(centralWidget)
     self.addMenu()
     self.tray = Systray(self)
     self.systray(zcswebapp.minimized)
     self.installEventFilter(self)
     if self.identifier is None:
         webView.load(QtCore.QUrl(Resources.SIGNIN_URL))
     else:
         webView.load(QtCore.QUrl(self.domain()))
     webView.show()
开发者ID:zerlgi,项目名称:zcswebapp,代码行数:34,代码来源:scudcloud.py


示例14: achieve_mission_found

 def achieve_mission_found(self):
     if not self.group.resources or\
             self.group.position.village_set.count() >= NB_VILLAGES_PER_TILE\
             or self.group.resources <\
             Resources.dict_to_resources(VILLAGE_CREATION_NEEDED_RESOURCES):
         self.come_back()
         self.group.log_report(
                 type=11,
                 subject='Impossible de créer le village',
                 body='Tous les emplacements de la case'
                     ' sélectionnée sont occupés ou bien '
                     'vous ne disposez pas de suffisamment de ressources',
                 )
     v = Village(
             name="New village",
             inhabitants=self.group,
             resources=Resources.objects.create(),
             tribe=self.group.village.tribe,
             position=self.group.position,
             )
     v.resources.save()
     v.save()
     v.update_income()
     self.group.village = v
     self.group.save()
     update_resources = v.receive_resources(self.group.resources)
     update_resources.save()
     self.group.resources = update_resources
     self.group.resources -= v.receive_resources(self.group.ressources)
     self.group.resources.save()
开发者ID:raphael-boucher,项目名称:dolmen,代码行数:30,代码来源:mission.py


示例15: __init__

 def __init__(self, window):
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path("leftpane.js"), "r") as f:
         self.js = f.read()
     # We don't want plugins for this simple pane
     self.settings().setAttribute(QWebSettings.PluginsEnabled, False)
     self.reset()
开发者ID:timesofbadri,项目名称:scudcloud,代码行数:8,代码来源:leftpane.py


示例16: calcadjvals

 def calcadjvals(self):
   self.setadjpoints()
   adjvals = []
   if self.scentview:
     for point in self.adjpoints:
       shortestdist = Resources.calcdistance(point, self.scentview[0].rect.center)
       normalizeddist = shortestdist/(self.current_scent_dist * math.sqrt(2))
       adjvals.append(1 - normalizeddist)
   return adjvals
开发者ID:eychung,项目名称:animats,代码行数:9,代码来源:wolf.py


示例17: __init__

 def __init__(self, window):
     self.configure_proxy()
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path("scudcloud.js"), "r") as f:
         self.js = f.read()
     self.setZoomFactor(self.window.zoom)
     self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
     self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged)
     self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
     self.addActions()
开发者ID:aikikode,项目名称:scudcloud,代码行数:11,代码来源:wrapper.py


示例18: play_hangup

    def play_hangup(self):
        settings = SIPSimpleSettings()

        if settings.audio.silent:
            return

        if time.time() - self.last_hangup_tone_time > HANGUP_TONE_THROTLE_DELAY:
            hangup_tone = WavePlayer(SIPApplication.voice_audio_mixer, Resources.get('hangup_tone.wav'), volume=30)
            NotificationCenter().add_observer(self, sender=hangup_tone, name="WavePlayerDidEnd")
            SIPApplication.voice_audio_bridge.add(hangup_tone)
            hangup_tone.start()
            self.last_hangup_tone_time = time.time()
开发者ID:wilane,项目名称:blink-cocoa,代码行数:12,代码来源:SessionRinger.py


示例19: urlChanged

 def urlChanged(self, qUrl):
     url = qUrl.toString()
     # Some integrations/auth will get back to /services with no way to get back to chat
     if Resources.SERVICES_URL_RE.match(url):
         self.systemOpen(url)
         self.load(QUrl("https://"+qUrl.host()+"/messages/general"))
     else:
         self.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(Resources.get_path("login.css")))
         self.inject()
         # Save the loading team as default
         if url.endswith("/messages"):
             self.window.settings.setValue("Domain", 'https://'+qUrl.host())
开发者ID:raonyguimaraes,项目名称:scudcloud,代码行数:12,代码来源:wrapper.py


示例20: filter_tokens

 def filter_tokens(self, tokens):
     new_tok = []
     for token in tokens:
         word = token['token']
         if self.conf.getboolean('global', 'remove_stopwords') and word in Resources.stopwords:
             continue
         if self.conf.getboolean('global', 'remove_punctuation') and word in Resources.punctuation:
             continue
         if self.conf.getboolean('global', 'filter_frequent_adverbs') and Resources.is_frequent_adverb(word, token['pos']):
             continue
         new_tok.append(token)
     return new_tok
开发者ID:pajkossy,项目名称:semeval,代码行数:12,代码来源:read_and_enrich.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python lib.TheMovieDB类代码示例发布时间:2022-05-26
下一篇:
Python resourceful.NeededResources类代码示例发布时间: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