def update_plugins(self): css = '#layout > div.add-ons > table > tbody > tr > td > a' per_page = 16 plugins_url = 'http://addons.silverstripe.org/add-ons?search=&type=module&sort=downloads&start=%s' themes_url = 'http://addons.silverstripe.org/add-ons?search=&type=theme&sort=downloads&start=%s' update_amount = 2000 plugins = [] for elem in ua.modules_get(plugins_url, per_page, css, update_amount, pagination_type=ua.PT.skip): plugins.append(elem.string) themes = [] for elem in ua.modules_get(themes_url, per_page, css, update_amount, pagination_type=ua.PT.skip): themes.append(elem.string) notification = "Converting composer packages into folder names %s/2." print(notification % (1)) plugins_folder = self._convert_to_folder(plugins) print(notification % (2)) themes_folder = self._convert_to_folder(themes) return plugins_folder, themes_folder
def test_modules_get(self): url = 'https://drupal.org/project/project_module?page=%s' css = '.node-project-module > h2 > a' per_page = 25 do_resp = codecs.open(dscan.PWD + 'tests/resources/drupal_org_response.html', encoding='utf-8').read() do_resp_last = codecs.open( dscan.PWD + 'tests/resources/drupal_org_response_partial.html').read() responses.add(responses.GET, 'https://drupal.org/project/project_module?page=0', body=do_resp, match_querystring=True) responses.add(responses.GET, 'https://drupal.org/project/project_module?page=1', body=do_resp, match_querystring=True) responses.add(responses.GET, 'https://drupal.org/project/project_module?page=2', body=do_resp_last, match_querystring=True) plugins = [] for plugin in modules_get(url, per_page, css): plugins.append(plugin) assert len(plugins) == 69
def update_plugins(self): """ @return: (plugins, themes) a tuple which contains two list of strings, the plugins and the themes. """ plugins_url = 'https://drupal.org/project/project_module?page=%s' plugins_css = '.node-project-module > h2 > a' themes_url = 'https://drupal.org/project/project_theme?page=%s' themes_css = '.node-project-theme > h2 > a' per_page = 25 plugins = [] for elem in ua.modules_get(plugins_url, per_page, plugins_css): plugins.append(elem['href'].split("/")[-1]) themes = [] for elem in ua.modules_get(themes_url, per_page, themes_css): themes.append(elem['href'].split("/")[-1]) return plugins, themes
def test_modules_get(self): url = 'https://drupal.org/project/project_module?page=%s' css = '.node-project-module > h2 > a' per_page = 25 do_resp = codecs.open(dscan.PWD + 'tests/resources/drupal_org_response.html', encoding='utf-8').read() do_resp_last = codecs.open(dscan.PWD + 'tests/resources/drupal_org_response_partial.html', 'r', 'utf-8').read() responses.add(responses.GET, 'https://drupal.org/project/project_module?page=0', body=do_resp, match_querystring=True) responses.add(responses.GET, 'https://drupal.org/project/project_module?page=1', body=do_resp, match_querystring=True) responses.add(responses.GET, 'https://drupal.org/project/project_module?page=2', body=do_resp_last, match_querystring=True) plugins = [] for plugin in modules_get(url, per_page, css): plugins.append(plugin) assert len(plugins) == 69