def check_visible(file_name): """ Check whether file is ApexTrigger, ApexComponent, ApexPage or ApexClass Parameters: file_name: current file name Return: Bool """ if file_name == None: return False # Get toolingapi settings toolingapi_settings = context.get_toolingapi_settings() # Get component_type component_type = util.get_component_type(file_name) # If component type is not in range, just show error message if component_type not in toolingapi_settings["component_types"]: return False # Get component_url and component_id username = toolingapi_settings["username"] try: component_attribute = util.get_component_attribute(username, file_name) except KeyError as err: return False if component_attribute == None: return False return True
def get_component_attribute(file_name): # Get toolingapi settings toolingapi_settings = context.get_toolingapi_settings() # Get component type component_name = util.get_component_name(file_name) component_type = util.get_component_type(file_name) # If component type is not in range, just show error message if component_type not in toolingapi_settings["component_types"]: return # Get component_url and component_id username = toolingapi_settings["username"] component_attribute = util.get_component_attribute(username, file_name) return (component_attribute, component_name)