當前位置: 首頁>>代碼示例>>Python>>正文


Python inventory.Inventory方法代碼示例

本文整理匯總了Python中inventory.Inventory方法的典型用法代碼示例。如果您正苦於以下問題:Python inventory.Inventory方法的具體用法?Python inventory.Inventory怎麽用?Python inventory.Inventory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在inventory的用法示例。


在下文中一共展示了inventory.Inventory方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def __init__(self, args, logger=None, mode=None):
    self.commandLine = CommandLine(args)
    if mode is not None:
      self.commandLine.mode = mode
    if logger is None:
      logging.basicConfig(format="%(asctime)-15s %(levelname)s [%(filename)s:%(lineno)d-%(thread)d] %(message)s")
      logger = logging.getLogger()
      logger.setLevel(logging.INFO)
    self.logger = logger

    self.mode = self.__detectMode(self.commandLine.mode)
    self.config = self.__loadConfig()
    self.inventory = Inventory(logger, self.config)
    self.commands = { 
      'migrate': MigrateCommand(self),
      'list-migrations': ListMigrationsCommand(self),
      'version': VersionCommand(self),
      'help':HelpCommand(self) }
    self.defaultCommand = HelpCommand(self) 
開發者ID:server-mechanic,項目名稱:mechanic,代碼行數:21,代碼來源:context.py

示例2: __init__

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def __init__(self, session, authProvider, accessToken, location):
        self.session = session
        self.authProvider = authProvider
        self.accessToken = accessToken
        self.location = location
        if self.location.noop:
            logging.info("Limited functionality. No location provided")

        self._state = State()

        self.authTicket = None
        self.endpoint = None
        self.endpoint = 'https://{0}{1}'.format(
            self.createApiEndpoint(),
            '/rpc'
        )

        # Set up Inventory
        self.getInventory() 
開發者ID:cglatot,項目名稱:PokeManager,代碼行數:21,代碼來源:session.py

示例3: parseDefault

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def parseDefault(self, res):
        try:
            self._state.eggs.ParseFromString(res.returns[1])
            self._state.inventory.ParseFromString(res.returns[2])
            self._state.badges.ParseFromString(res.returns[3])
            self._state.settings.ParseFromString(res.returns[4])
        except Exception as e:
            logging.error(e)
            raise GeneralPogoException("Error parsing response. Malformed response")

        # Finally make inventory usable
        item = self._state.inventory.inventory_delta.inventory_items
        self.inventory = Inventory(item)

    # Hooks for those bundled in default
    # Getters 
開發者ID:cglatot,項目名稱:PokeManager,代碼行數:18,代碼來源:session.py

示例4: setUp

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def setUp(self):
      logger = MagicMock()
      config = MagicMock()
      self.inventory = Inventory(logger=logger, config=config)
      self.inventoryDb = MagicMock()
      self.inventory.inventoryDb = self.inventoryDb
      tempDir = tempfile.mkdtemp()
      config.migrationDirs = [tempDir]
      config.preMigrationDirs = [tempDir]
      config.postMigrationDirs = [tempDir] 
開發者ID:server-mechanic,項目名稱:mechanic,代碼行數:12,代碼來源:inventory_test.py

示例5: run

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def run(self, inventory=None):

        if inventory is not None:
            self.inventory = inventory

        try:
            if isinstance(self.inventory, Inventory):
                self.inventory.to_file(self.inventory_path)
                self.logger.debug("Saved inventory file to %s" % self.inventory_path)

            return self._run()

        finally:
            self.cleanup() 
開發者ID:OpenDataAnalytics,項目名稱:dauber,代碼行數:16,代碼來源:playbook.py

示例6: cleanup

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def cleanup(self):
        if isinstance(self.inventory, Inventory):
            try:
                os.remove(self.inventory_path)
                self.logger.debug("Cleaned up %s" % self.inventory_path)
            except IOError:
                pass

            self._inventory_path = None 
開發者ID:OpenDataAnalytics,項目名稱:dauber,代碼行數:11,代碼來源:playbook.py

示例7: inventory_path

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def inventory_path(self):
        if self._inventory_path is None:
            if isinstance(self.inventory, basestring):
                self._inventory_path = self.inventory
            elif isinstance(self.inventory, Inventory):
                _, self._inventory_path  = tempfile.mkstemp()

        return self._inventory_path 
開發者ID:OpenDataAnalytics,項目名稱:dauber,代碼行數:10,代碼來源:playbook.py

示例8: getDefaults

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def getDefaults():
        # Allocate for 4 default requests
        data = [None, ] * 4

        # Create Egg request
        data[0] = Request_pb2.Request(
            request_type=RequestType_pb2.GET_HATCHED_EGGS
        )

        # Create Inventory Request
        data[1] = Request_pb2.Request(
            request_type=RequestType_pb2.GET_INVENTORY,
            request_message=GetInventoryMessage_pb2.GetInventoryMessage(
                last_timestamp_ms=0
            ).SerializeToString()
        )

        # Create Badge request
        data[2] = Request_pb2.Request(
            request_type=RequestType_pb2.CHECK_AWARDED_BADGES
        )

        # Create Settings request
        data[3] = Request_pb2.Request(
            request_type=RequestType_pb2.DOWNLOAD_SETTINGS,
            request_message=DownloadSettingsMessage_pb2.DownloadSettingsMessage(
                hash="4a2e9bc330dae60e7b74fc85b98868ab4700802e"
            ).SerializeToString()
        )

        return data

    # Parse the default responses 
開發者ID:cglatot,項目名稱:PokeManager,代碼行數:35,代碼來源:session.py

示例9: load

# 需要導入模塊: import inventory [as 別名]
# 或者: from inventory import Inventory [as 別名]
def load(cls, vnum: int=None, instance_id: int=None):
        if instance_id:
            if instance_id in instance.rooms:
                logger.warn('Instance %d of room already loaded!', instance_id)
                return
            pathname = settings.INSTANCE_DIR
            number = instance_id
        elif vnum:
            pathname = settings.AREA_DIR
            number = vnum
        else:
            raise ValueError('To load a Room, you must provide either a VNUM or an Instance_ID!')

        if settings.SAVE_FORMAT['Pickle'][0]:
            target_file = '%d-room%s' % (number, settings.SAVE_FORMAT['Pickle'][1])
        elif settings.SAVE_FORMAT['JSON'][0]:
            target_file = '%d-room%s' % (number, settings.SAVE_FORMAT['JSON'][1])
        else:
            target_file = '%d-room.json' % (number,)
        filename = None
        for a_path, a_directory, i_files in os.walk(pathname):
            if target_file in i_files:
                filename = os.path.join(a_path, target_file)
                break
        if not filename:
            raise ValueError('Cannot find %s' % target_file)
        jso = ''
        if settings.SAVE_FORMAT['JSON'][0]:
            #json version
            with open(filename, 'r+') as f:
                #this reads in one line at a time from stdin - way faster. Syn
                for line in f:
                    jso += line
        else:
            #pickle version
            import pickle
            with open(filename, 'rb') as f:
                jso = pickle.load(f)
        obj = json.loads(jso, object_hook=instance.from_json)
        if isinstance(obj, Room):
            # Inventory is already loaded by Room's __init__ function.
            return obj
        else:
            logger.error('Could not load room data for %d', number)
            return None 
開發者ID:bodrich,項目名稱:pyom_mud,代碼行數:47,代碼來源:handler_room.py


注:本文中的inventory.Inventory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。