Skip to content

Instantly share code, notes, and snippets.

@gridhead
Last active September 27, 2020 09:33
Show Gist options
  • Save gridhead/53171901be512c6c766f208c440f361d to your computer and use it in GitHub Desktop.
Save gridhead/53171901be512c6c766f208c440f361d to your computer and use it in GitHub Desktop.
Transferring issues from Pagure to GitHub

Transferring issues from Pagure to Github

Akashdeep Dhar. t0xic0der

The following snippet of Python code uses Selenium Webdriver and JSON to scrape through the issues available at Pagure and copies them into a dictionary. The same dictionary is then parsed into a JSON string and then written to a file.

from selenium import webdriver
import json

def getissue(link:str, brws:webdriver):
    brws.get(link)
    rowelist = brws.find_elements_by_css_selector("div.issuerow")
    issulist, issuqant = [], 0
    for roweindx in rowelist:
        issulist.append({
            "issuqant": str(roweindx.find_element_by_css_selector("span.text-success.font-weight-bold").get_attribute("innerHTML")).strip(),
            "issuname": str(roweindx.find_element_by_css_selector("a.notblue").get_attribute("innerHTML")).strip(),
            "issulink": str(roweindx.find_element_by_css_selector("a.notblue").get_attribute("href")).strip(),
            "issutags": [str(jndx.get_attribute("innerHTML")).strip() for jndx in roweindx.find_elements_by_css_selector("a.badge")]
        })
        issuqant += 1
    return issuqant, issulist


def mainfunc():
    print("ISSUE TRANSFERENCE")
    link = "https://pagure.io/fedora-join/Fedora-Join/issues"
    brws = webdriver.Chrome(executable_path="/home/t0xic0der/Projects/transference/chromedriver")
    rslt = getissue(link, brws)
    open("issulist.json", "w").write(json.dumps(rslt[1]))
    print(rslt[0], "issues were transferred to 'issulist.json'")


mainfunc()

The further actions would include using the GitHub CLI which very recently came out Beta to automate creation of issues in the given repository on GitHub. Do make sure to setup a push mirror for the same before that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment