Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arl_changes #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,003 changes: 0 additions & 1,003 deletions README-ActionScript.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Assembly.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-C.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-CPP.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-CSharp.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Clojure.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-CoffeeScript.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Crystal.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-D.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Elixir.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Elm.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Erlang.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Go.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Groovy.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Haskell.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Idris.md

This file was deleted.

1 change: 0 additions & 1 deletion README-JS.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Java.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-JavaScript.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Kotlin.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Lua.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-MATLAB.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Node.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-ObjectiveC.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-PHP.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Perl.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-PureScript.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Python.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-R.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Ruby.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Rust.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-SQL.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Scala.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Swift.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-TypeScript.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-V.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-VB.net.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-VHDL.md

This file was deleted.

1,003 changes: 0 additions & 1,003 deletions README-Verilog.md

This file was deleted.

56 changes: 15 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,19 @@ Got a new programming language to learn?

Below is the list of lists of most popular repositories, sorted by number of stars, for each of the most favoured programming languages
(according to [StackOverflow](https://insights.stackoverflow.com/survey/2017)):
* [Python](https://github.com/kaxap/arl/blob/master/README-Python.md)
* [JavaScript](https://github.com/kaxap/arl/blob/master/README-JavaScript.md)
* [Java](https://github.com/kaxap/arl/blob/master/README-Java.md)
* [C](https://github.com/kaxap/arl/blob/master/README-C.md)
* [C++](https://github.com/kaxap/arl/blob/master/README-CPP.md)
* [NodeJS](https://github.com/kaxap/arl/blob/master/README-Node.md)
* [C#](https://github.com/kaxap/arl/blob/master/README-CSharp.md)
* [PHP](https://github.com/kaxap/arl/blob/master/README-PHP.md)
* [Ruby](https://github.com/kaxap/arl/blob/master/README-Ruby.md)
* [TypeScript](https://github.com/kaxap/arl/blob/master/README-TypeScript.md)
* [Swift](https://github.com/kaxap/arl/blob/master/README-Swift.md)
* [Objective-C](https://github.com/kaxap/arl/blob/master/README-ObjectiveC.md)
* [VB.net](https://github.com/kaxap/arl/blob/master/README-VB.net.md)
* [Assembly](https://github.com/kaxap/arl/blob/master/README-Assembly.md)
* [R](https://github.com/kaxap/arl/blob/master/README-R.md)
* [Perl](https://github.com/kaxap/arl/blob/master/README-Perl.md)
* [MATLAB](https://github.com/kaxap/arl/blob/master/README-MATLAB.md)
* [Go](https://github.com/kaxap/arl/blob/master/README-Go.md)
* [Scala](https://github.com/kaxap/arl/blob/master/README-Scala.md)
* [Groovy](https://github.com/kaxap/arl/blob/master/README-Groovy.md)
* [Lua](https://github.com/kaxap/arl/blob/master/README-Lua.md)
* [Haskell](https://github.com/kaxap/arl/blob/master/README-Haskell.md)
* [CoffeeScript](https://github.com/kaxap/arl/blob/master/README-CoffeeScript.md)
* [Clojure](https://github.com/kaxap/arl/blob/master/README-Clojure.md) is not on SO's list, but it's very popular on its own.
* [Rust](https://github.com/kaxap/arl/blob/master/README-Rust.md) same as previous
* [ActionScript](https://github.com/kaxap/arl/blob/master/README-ActionScript.md)
* [Elixir](https://github.com/kaxap/arl/blob/master/README-Elixir.md)
* [Erlang](https://github.com/kaxap/arl/blob/master/README-Erlang.md)
* [Idris](https://github.com/kaxap/arl/blob/master/README-Idris.md)
* [Elm](https://github.com/kaxap/arl/blob/master/README-Elm.md)
* [PureScript](https://github.com/kaxap/arl/blob/master/README-PureScript.md)
* [Crystal](https://github.com/kaxap/arl/blob/master/README-Crystal.md)
* [D](https://github.com/kaxap/arl/blob/master/README-D.md)
* [Kotlin](https://github.com/kaxap/arl/blob/master/README-Kotlin.md)
* [V](https://github.com/kaxap/arl/blob/master/README-V.md)
* [Verilog](https://github.com/kaxap/arl/blob/master/README-Verilog.md)
* [VHDL](https://github.com/kaxap/arl/blob/master/README-VHDL.md)

The list is being updated every Sunday.

### Can't find your programming language?
Feel free to create an issue.
<!-- start_links -->
* [Python](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/01_Python.md)
* [Node](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/02_Node.md)
* [JavaScript](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/03_JavaScript.md)
* [Java](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/04_Java.md)
* [CPP](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/05_CPP.md)
* [Rust](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/06_Rust.md)
* [C](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/07_C.md)
* [CSharp](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/08_CSharp.md)
* [PHP](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/09_PHP.md)
* [Kotlin](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/10_Kotlin.md)
* [MATLAB](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/11_MATLAB.md)
* [Verilog](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/12_Verilog.md)
* [SystemVerilog](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/13_SystemVerilog.md)
* [SQL](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/14_SQL.md)
95 changes: 95 additions & 0 deletions file_lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import os
import glob

from param_repo import *

DBG = 0

sign_strt_link = "<!-- start_links -->"

def README_add_links ():

file_link = open(f"links.md", "r", encoding="utf-8")
file_RDME = open(f"README.md", "a+", encoding="utf-8")

pos_sign = 0
file_RDME.seek(0)
#clean links
for line in file_RDME.readlines():

pos_sign += len(line)+1 #\n == CRLF
if sign_strt_link in line :
file_RDME.truncate(pos_sign)
file_RDME.flush()
print(f"pos_sign={pos_sign}")

break


#insert lines
str_links = file_link.readlines()

file_RDME.writelines(str_links)

file_link.close()
file_RDME.close()


def get_file_name(path):
if not os.path.isdir(path):
return os.path.splitext(os.path.basename(path))[0].split(".")[0]


def get_dir_name ( full_file_name):
# dirname = os.path.basename(full_path_file_name)
dirname = os.path.dirname(full_file_name)
return dirname

def file_ranames_to_rate_lngs (lng_rate, path ) :

ext = 'md'
file_link = open(f"links.md", "w", encoding="utf-8")
list_files = glob.glob( f'{path}/*.{ext}')

for full_path_to_file in list_files:

# print( f'full_path_to_file ={full_path_to_file}')

file_name = get_file_name(full_path_to_file)

if DBG == 1:
print ( f'file_name={file_name}+ {file_name[3:]}')

for ind,el in enumerate(lng_rate) :

cnt_stars = el[1]
lng_name = el[0]
if DBG == 1:
print( f'lng={cnt_stars} lng_name={lng_name}')

if lng_name in file_name and (len(lng_name) == len(file_name[3:]) ) :

dir_name = get_dir_name( full_path_to_file)
new_name = f'{path}/' + "%02d" % (ind+1) + '_' + str(lng_name) + "." + ext

try:

# os.rename(full_path_to_file, new_name)
if DBG == 1 :
print (f'full_path_to_file={full_path_to_file} , new_name={new_name}')
# break
except IOError:
continue

# Gen links
_str = f'* [{lng_name}](https://github.com/{repo_user_name}/{repo_name}/blob/master/{new_name}) \n'
file_link.write (_str)

print (_str)







14 changes: 14 additions & 0 deletions links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
* [Python](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/01_Python.md)
* [Node](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/02_Node.md)
* [JavaScript](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/03_JavaScript.md)
* [Java](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/04_Java.md)
* [CPP](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/05_CPP.md)
* [Rust](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/06_Rust.md)
* [C](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/07_C.md)
* [CSharp](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/08_CSharp.md)
* [PHP](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/09_PHP.md)
* [Kotlin](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/10_Kotlin.md)
* [MATLAB](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/11_MATLAB.md)
* [Verilog](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/12_Verilog.md)
* [SystemVerilog](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/13_SystemVerilog.md)
* [SQL](https://github.com/ElPrg/popl_reps_by_stars_in_langs-arl-/blob/master/output_rates_repos/14_SQL.md)
139 changes: 95 additions & 44 deletions make.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ﷽

import json
from typing import Optional

Expand All @@ -9,33 +9,43 @@
import argparse

from requests.adapters import HTTPAdapter
from requests.packages.urllib3 import Retry
from urllib3 import Retry

from requests.structures import CaseInsensitiveDict

# loc imports
import file_lib as fil
from param_repo import *


# Tables formates list data repos
TABLE_DISCLAIMER = "## This is a most popular repository list for {lng} sorted by number of stars"
TABLE_HEADER = "|STARS|FORKS|ISSUES|LAST COMMIT|NAME/PLACE|DESCRIPTION|"
TABLE_SEPARATOR = "| --- | --- | --- | --- | --- | --- |"
TABLE_ITEM_MASK = "| {n_stars} | {n_forks} | {n_issues} | {updated_at} | [{name}]({url})/{place} | {description} |"
MAX_PAGE = 10

MAX_PAGE = 2
# MAX_PAGE = 10
MAX_PER_PAGE = 100


URL_MASK = "https://api.github.com/search/repositories" \
"?q=language:{lng}&sort=stars&order=desc&page={n_page}&per_page=100"
"?q=language:{lng}&sort=stars&order=desc&page={n_page}&per_page={per_page}"
LAST_COMMIT_URL_MASK = "https://api.github.com/repos/{repo_full_name}/commits"

KEY_STAR_COUNT = "stargazers_count"
KEY_ISSUE_COUNT = "open_issues"
KEY_FORK_COUNT = "forks"
KEY_REPOSITORY_NAME = "name"
KEY_REPOSITORY_FULL_NAME = "full_name"
KEY_DESCRIPTION = "description"
KEY_URL = "html_url"
KEY_ITEMS = "items"
KEY_UPDATED_AT = 'updated_at'
KEY_STAR_COUNT = "stargazers_count"
KEY_ISSUE_COUNT = "open_issues"
KEY_FORK_COUNT = "forks"
KEY_REPOSITORY_NAME = "name"
KEY_REPOSITORY_FULL_NAME = "full_name"
KEY_DESCRIPTION = "description"
KEY_URL = "html_url"
KEY_ITEMS = "items"
KEY_UPDATED_AT = 'updated_at'


languages = ["Verilog", "VHDL", "V", "Erlang", "Kotlin", "D", "Crystal", "Idris", "Python", "Java", "C", "CPP", "SQL",
"Node", "CSharp", "PHP", "Ruby", "TypeScript", "Swift", "ObjectiveC",
"VB.net", "Assembly", "R", "Perl", "MATLAB", "Go", "Scala", "Groovy", "Lua", "Haskell", "CoffeeScript",
"Clojure", "Rust", "JavaScript", "ActionScript", "Elixir", "Elm", "PureScript"]
languages = ["SystemVerilog", "Verilog","CPP", "C", "Kotlin", "Java", "Python" , "JavaScript",
"Node", "CSharp", "PHP", "MATLAB", "SQL", "Rust" ]


class WrongReturnCodeException(Exception):
Expand All @@ -56,6 +66,7 @@ def __init__(self):
self.session.mount("https://", adapter)
with open("token.json", "r") as tf:
token = json.load(tf)["token"]

self.session.headers = {
"Authorization": f"token {token}",
"User-Agent": "Another Repository List",
Expand All @@ -82,16 +93,17 @@ def get_next(self, language: str, n_page: int, request_timeout=20.0) -> dict:
"""

print(f"Requesting page #{n_page} for {language}")
response = self.session.get(URL_MASK.format(n_page=n_page, lng=language), timeout=request_timeout)
response = self.session.get(URL_MASK.format(n_page=n_page, lng=language,per_page=MAX_PER_PAGE), timeout=request_timeout)
try:
if response.ok:
return response.json()
else:
# rate limiting?
if self.obey_rate_limit(response.headers):
# if 1:
return self.get_next(language, n_page)

raise WrongReturnCodeException(response.text)
# raise WrongReturnCodeException(response.text)
finally:
response.close()

Expand All @@ -109,6 +121,7 @@ def get_last_commit_date(self, repo_full_name: Optional[str]) -> Optional[str]:
if response.ok:
return response.json()[0]["commit"]["author"]["date"]
else:
# if 1:
if self.obey_rate_limit(response.headers):
return self.get_last_commit_date(repo_full_name)
except KeyError:
Expand All @@ -125,7 +138,7 @@ def humanize_date(iso_date: str) -> str:
return "Unknown"


def generate_readme(language: str, info_provider: RepositoryInformationProvider) -> str:
def generate_md_files_with_list_repos(language: str, info_provider: RepositoryInformationProvider) -> str:
"""
generates a README markdown file with a table of most popular repositories for a given language
:param language: programming language such as python or go
Expand All @@ -137,40 +150,78 @@ def generate_readme(language: str, info_provider: RepositoryInformationProvider)
TABLE_SEPARATOR]

place = 0

loc_n_stars=0
n_stars = 0

for n_page in range(1, MAX_PAGE + 1):

data: dict = info_provider.get_next(language, n_page)
for i, item in enumerate(data[KEY_ITEMS]):
last_commit_date = humanize_date(
info_provider.get_last_commit_date(item.get(KEY_REPOSITORY_FULL_NAME, None)))
place += 1
if(data is not None):
for i, item in enumerate(data[KEY_ITEMS]):
last_commit_date = humanize_date(
info_provider.get_last_commit_date(item.get(KEY_REPOSITORY_FULL_NAME, None)))
place += 1

desc = item.get(KEY_DESCRIPTION)
if desc:
desc = desc.replace("\n", " ")

n_stars=item.get(KEY_STAR_COUNT)
loc_n_stars += n_stars

desc = item.get(KEY_DESCRIPTION)
if desc:
desc = desc.replace("\n", " ")
result.append(TABLE_ITEM_MASK.format(n_stars =n_stars,
n_forks =item.get(KEY_FORK_COUNT),
n_issues =item.get(KEY_ISSUE_COUNT),
name =item.get(KEY_REPOSITORY_NAME),
url =item.get(KEY_URL),
description=desc,
place =place,
updated_at=last_commit_date))
print(f"{i + 1}/{len(data[KEY_ITEMS])}/{n_page}")

result.append(TABLE_ITEM_MASK.format(n_stars=item.get(KEY_STAR_COUNT),
n_forks=item.get(KEY_FORK_COUNT),
n_issues=item.get(KEY_ISSUE_COUNT),
name=item.get(KEY_REPOSITORY_NAME),
url=item.get(KEY_URL),
description=desc,
place=place,
updated_at=last_commit_date))
print(f"{i + 1}/{len(data[KEY_ITEMS])}/{n_page}")
return loc_n_stars,"\n".join(result)

return "\n".join(result)


if __name__ == "__main__":

# parse command-line arguments
parser = argparse.ArgumentParser()
parser.add_argument("--langs", type=str, help="comma-separated language names", default=",".join(languages))
args = parser.parse_args()
languages = [l.strip() for l in args.langs.split(",")]
# parser = argparse.ArgumentParser()
# parser.add_argument("--langs", type=str, help="comma-separated language names", default=",".join(languages))
# args = parser.parse_args()
# languages = [l.strip() for l in args.langs.split(",")]




lng_rate = []
provider = RepositoryInformationProvider()
for lng in languages:
readme = generate_readme(lng, provider)
with open(f"README-{lng}.md", "w", encoding="utf-8") as f:
f.write(readme)

# ---test----
# import random
# cnt_strs, readme = random.randrange(30), lng

# work
cnt_strs, readme = generate_md_files_with_list_repos(lng, provider)

if cnt_strs != 0:
lng_rate.append ( (lng,cnt_strs))

with open(f"{repo_out_path}/lng_{lng}.md", "w+", encoding="utf-8") as f:
f.write(readme)

print(f'lng_rate={lng_rate}')
# set rate langs for filenames
lng_rate = sorted(lng_rate, key=lambda x: x[1], reverse=True )

print(f'sorted_lng_rate={lng_rate}')

# lng_rate=[('Python', 8328288), ('Node', 7970087), ('JavaScript', 7970086), ('Java', 4536509), ('CPP', 4402521), ('Rust', 3387501), ('C', 3113744), ('CSharp', 2222923), ('PHP', 2136581), ('Kotlin', 1515987), ('MATLAB', 156093), ('Verilog', 81805), ('SystemVerilog', 39984), ('SQL', 5268)]

fil.file_ranames_to_rate_lngs(lng_rate, repo_out_path)

fil.README_add_links ()

print ( "Finish !!!")
Loading