def get_pd_file_list(self): self.driver_files_list = [] temp = get_paths_of_subfiles(self.pd_dir, extension=re.compile("\.py$")) for driver_file in temp: if not get_dir_from_path(driver_file) == "__init__.py": self.driver_files_list.append(driver_file) return self.driver_files_list
def set_apps(self, data): """ call this to build Apps array and make app objects """ self.get_config_paths(data) for url in self.paths: json_data = read_json_data(url) if json_data is not None: app_path = get_parent_directory(url) app = App(json_data, app_path, data["base_directory"]) js_urls = get_paths_of_subfiles( join_path(app_path, app.static_file_dir, "js"), extension=compile_regex("^\.js$")) for i in range(0, len(js_urls)): js_urls[i] = get_relative_path(js_urls[i], app_path) app.data["js_urls"] = js_urls self.apps.append(app) return self.apps
def __map_actions_to_driver(self): actions_for_driver_dict = self.__get_action_packages() for driver_file, actions_package_list in actions_for_driver_dict.items( ): actions_dir_paths = [] for actions_package in actions_package_list: actions_dir_paths.append( os.path.join(self.repo_directory, actions_package.replace(".", os.sep))) actions_file_paths = [] for actions_package in actions_dir_paths: temp = get_paths_of_subfiles(actions_package, extension=re.compile("\.py$")) for actions_file in temp: if not get_dir_from_path(actions_file) == "__init__.py": actions_file_paths.append(actions_file) actions_for_driver_dict[driver_file] = copy.copy( actions_file_paths) return actions_for_driver_dict
def __validate_static_directory(self): output = {"status": True, "message": ""} if os.path.isdir(join_path(self.path_to_app, "static")): subs = get_sub_dirs_and_files(join_path(self.path_to_app, "static")) if len(subs["files"]) > 0: output["status"] = False output["message"] = "static directory does not follow the required " \ "directory structure." print("-- An Error Occurred -- {0}".format(output["message"])) else: if not os.path.isdir( join_path(self.path_to_app, "static", self.app_name)): output["status"] = False output["message"] = "static directory does not follow the required " \ "directory structure." print("-- An Error Occurred -- {0}".format( output["message"])) else: subs_files = get_paths_of_subfiles( join_path(self.path_to_app, "static", self.app_name), re.compile("\.js$")) path_to_js = join_path(self.path_to_app, "static", self.app_name, "js") if not self.django_based: # Validates JS structure only if app uses old Katana API list_of_files = ", ".join([ x for x in subs_files if not x.startswith(path_to_js) ]) if list_of_files: output["status"] = False output["message"] = "A .js file cannot be outside the 'js' folder. " \ "List of files in non-compliance: {0}".format(list_of_files) print("-- An Error Occurred -- {0}".format( output["message"])) return output
def _get_action_files(actions_directory): """ This function gets the path to the action files """ return get_paths_of_subfiles(actions_directory, extension=compile_regex("^\.py$"))