This repository was archived by the owner on Jul 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAor.py
More file actions
51 lines (46 loc) · 2.47 KB
/
Aor.py
File metadata and controls
51 lines (46 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Tony Benoy"
__license__ = "GPL-3"
__version__ = "0.0.1"
__status__ = "Beta"
import requests
def aor_search(name = None, desc = None, pkg = None, repo = None, arch = None, maintainer = None, packager = None, flagged=None):
url = "https://www.archlinux.org/packages/search/json/"
if name != None:
querystring = {"name":name}
elif desc != None:
print(desc)
querystring = {"desc":desc}
elif pkg != None:
if repo!=None:
if repo not in ['Core', 'Extra', 'Testing', 'Multilib', 'Multilib-Testing', 'Community', 'Community-Testing']:
raise Exception("Repository not available in Arch Linux!")
if arch!=None:
if arch not in ['any', 'i686', 'x86_64']:
raise Exception("Architecture not available in Arch Linux!")
if flagged!=None:
if flagged not in ["Flagged", "Not+Flagged"]:
raise Exception("Flagged parameter incorrect!")
querystring = {"q":pkg,"repo":repo,"maintainer":maintainer,"arch":arch,"packager":packager}
else:
raise Exception("Not enough parameters to perform query!")
response = requests.request("GET", url, params=querystring)
return response.text
def package(repo ,arch,name):
if repo not in ['Core', 'Extra', 'Testing', 'Multilib', 'Multilib-Testing', 'Community', 'Community-Testing']:
raise Exception("Repository not available in Arch Linux! See available Repositories at https://wiki.archlinux.org/index.php/Official_repositories_web_interface#Repository")
if arch not in ['any', 'i686', 'x86_64']:
raise Exception("Architecture not available in Arch Linux!See available Architecture at https://wiki.archlinux.org/index.php/Official_repositories_web_interface#Architecture")
url = "https://www.archlinux.org/packages"+"/"+repo+"/"+arch+"/"+name+"/json"
response = requests.request("GET", url)
return response.text
def packagefiles(repo ,arch,name):
if repo not in ['Core', 'Extra', 'Testing', 'Multilib', 'Multilib-Testing', 'Community', 'Community-Testing']:
raise Exception("Repository not available in Arch Linux!")
if arch not in ['any', 'i686', 'x86_64']:
raise Exception("Architecture not available in Arch Linux!")
url = "https://www.archlinux.org/packages"+"/"+repo+"/"+arch+"/"+name+"/files/json"
response = requests.request("GET", url)
return response.text