コード例 #1
0
    def __init__(self, cmp_path=None):
        # using classname otherwise exceptions in superclasses won't show
        GenericUICommand.__init__(self, cmp_path=cmp_path, needs_script=False)
        # find content file
        self.script_file = \
            self.find_bundle_file([
                exts.CONTENT_VERSION_POSTFIX.format(
                    version=HOST_APP.version
                    ),
                ])
        if not self.script_file:
            self.script_file = \
                self.find_bundle_file([
                    exts.CONTENT_POSTFIX,
                    ])
        # requires at least one bundles
        if self.directory and not self.script_file:
            mlogger.error('Command %s: Does not have content file.', self)
            self.script_file = ''

        # find alternative content file
        self.config_script_file = \
            self.find_bundle_file([
                exts.ALT_CONTENT_VERSION_POSTFIX.format(
                    version=HOST_APP.version
                    ),
                ])
        if not self.config_script_file:
            self.config_script_file = \
                self.find_bundle_file([
                    exts.ALT_CONTENT_POSTFIX,
                    ])
        if not self.config_script_file:
            self.config_script_file = ''
コード例 #2
0
    def __init__(self, cmp_path=None, needs_commandclass=False):
        # using classname otherwise exceptions in superclasses won't show
        GenericUICommand.__init__(self, cmp_path=cmp_path, needs_script=False)
        self.assembly = self.command_class = self.avail_command_class = None
        # read metadata from metadata file
        if self.meta:
            # get the target assembly from metadata
            self.assembly = \
                self.meta.get(exts.MDATA_LINK_BUTTON_ASSEMBLY, None)

            # get the target command class from metadata
            self.command_class = \
                self.meta.get(exts.MDATA_LINK_BUTTON_COMMAND_CLASS, None)

            # get the target command class from metadata
            self.avail_command_class = \
                self.meta.get(exts.MDATA_LINK_BUTTON_AVAIL_COMMAND_CLASS, None)

            # for invoke buttons there is no script source so
            # assign the metadata file to the script
            self.script_file = self.config_script_file = self.meta_file
        else:
            mlogger.debug("%s does not specify target assembly::class.", self)

        if self.directory and not self.assembly:
            mlogger.error("%s does not specify target assembly.", self)

        if self.directory and needs_commandclass and not self.command_class:
            mlogger.error("%s does not specify target command class.", self)

        mlogger.debug('%s assembly.class: %s.%s', self, self.assembly,
                      self.command_class)
コード例 #3
0
ファイル: components.py プロジェクト: lionelcamara/pyRevit
 def __init__(self):
     GenericUICommand.__init__(self)
     self.icon_on_file = self.icon_off_file = None
     if self.name:
         logger.deprecate('{} | Toggle bundle is deprecated and will be '
                          'removed soon. Please use SmartButton bundle, '
                          'or any other bundle and use script.toggle_icon '
                          'method to toggle the tool icon.'
                          .format(self.name))
コード例 #4
0
ファイル: components.py プロジェクト: tatlin/pyRevit
    def __init__(self, cmp_path=None, needs_commandclass=False):
        # using classname otherwise exceptions in superclasses won't show
        GenericUICommand.__init__(self, cmp_path=cmp_path, needs_script=False)
        self.assembly = self.command_class = None
        # to support legacy linkbutton types using python global var convention
        # if has python script, read metadata
        if self.script_language == exts.PYTHON_LANG:
            try:
                # reading script file content to extract parameters
                script_content = \
                    coreutils.ScriptFileParser(self.script_file)

                self.assembly = \
                    script_content.extract_param(exts.LINK_BUTTON_ASSEMBLY)

                self.command_class = \
                    script_content.extract_param(exts.LINK_BUTTON_COMMAND_CLASS)

                if self.assembly or self.command_class:
                    mlogger.deprecate(
                        "Creating link buttons using \"__assembly__\" "
                        "and \"__commandclass__\" global "
                        "variables inside a python file is deprecated. "
                        "use bundle.yaml instead. | %s", self)

            except PyRevitException as err:
                mlogger.error(err)

        # otherwise read metadata from metadata file
        elif self.meta:
            # get the target assembly from metadata
            self.assembly = \
                self.meta.get(exts.MDATA_LINK_BUTTON_ASSEMBLY, None)

            # get the target command class from metadata
            self.command_class = \
                self.meta.get(exts.MDATA_LINK_BUTTON_COMMAND_CLASS, None)

            # for invoke buttons there is no script source so
            # assign the metadata file to the script
            self.script_file = self.config_script_file = self.meta_file
        else:
            mlogger.debug("%s does not specify target assembly::class.", self)

        if not self.assembly:
            mlogger.error("%s does not specify target assembly.", self)

        if needs_commandclass and not self.command_class:
            mlogger.error("%s does not specify target command class.", self)

        mlogger.debug('%s assembly.class: %s.%s',
                      self, self.assembly, self.command_class)
コード例 #5
0
    def __init__(self, cmp_path=None):
        # using classname otherwise exceptions in superclasses won't show
        GenericUICommand.__init__(self, cmp_path=cmp_path, needs_script=False)
        self.target_url = None
        # read metadata from metadata file
        if self.meta:
            # get the target url from metadata
            self.target_url = \
                self.meta.get(exts.MDATA_URL_BUTTON_HYPERLINK, None)
            # for url buttons there is no script source so
            # assign the metadata file to the script
            self.script_file = self.config_script_file = self.meta_file
        else:
            mlogger.debug("%s does not specify target assembly::class.", self)

        if self.directory and not self.target_url:
            mlogger.error("%s does not specify target url.", self)

        mlogger.debug('%s target url: %s', self, self.target_url)
コード例 #6
0
 def __init__(self):
     GenericUICommand.__init__(self)
     self.icon_on_file = self.icon_off_file = None
コード例 #7
0
 def __init__(self):
     GenericUICommand.__init__(self)
     self.assembly = self.command_class = None