This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
Add DebianPkgs module. #84
Closed
Closed
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d89ef7c
Add DebianPkgs module.
elebow 46d930d
debian_pkgs: add unstable repo
elebow 559acf8
debian_pkgs: put output fields in correct order
elebow c5c349b
debian_pkgs: add screenshots
elebow b030ca4
DebianPkgs: Change tabs to spaces.
elebow 6ad810f
DebianPkgs: Reuse code for each repo.
elebow 19abb81
DebianPkgs: Add some comments.
elebow 652809d
DebianPkgs: Fix typo in comment
elebow d6bc735
DebianPkgs: Show link only to first repo.
elebow File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package DDG::Fathead::DebianPkgs; | ||
|
||
use DDG::Fathead; | ||
|
||
primary_example_queries "debian vim"; | ||
secondary_example_queries | ||
"debian package plink", | ||
"netcat debian pkg"; | ||
description "Debian packages"; | ||
name "DebianPkgs"; | ||
source "Debian.org"; | ||
code_url "https://github.com/duckduckgo/zeroclickinfo-fathead/tree/master/share/debian_pkgs"; | ||
topics "linux", "sysadmin"; | ||
category "software"; | ||
|
||
1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
mkdir download | ||
wget https://packages.debian.org/stable/allpackages?format=txt.gz -O download/stable.txt.gz | ||
wget https://packages.debian.org/testing/allpackages?format=txt.gz -O download/testing.txt.gz | ||
wget https://packages.debian.org/unstable/allpackages?format=txt.gz -O download/unstable.txt.gz | ||
|
||
gunzip download/stable.txt.gz | ||
gunzip download/testing.txt.gz | ||
gunzip download/unstable.txt.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/python3 | ||
|
||
repos = ["stable", "testing", "unstable"] | ||
|
||
lines = {} | ||
names = {} | ||
pkgs = {} | ||
|
||
for repo in repos: | ||
with open("download/%s.txt" % repo) as f: | ||
lines[repo] = f.readlines() | ||
|
||
names[repo] = lines[repo][0].rsplit(" ", 1)[1].strip("\"\n") #the codename of each repo is in the first line | ||
|
||
lines[repo] = lines[repo][6:] #omit the 6 lines of header | ||
|
||
for p in lines[repo]: | ||
(name, ver, desc) = p.split(" ", 2) | ||
|
||
if name not in pkgs.keys(): | ||
pkgs[name] = {} #this dict will hold the package's (ver, desc) from each of the three repos. Some may not exist. | ||
|
||
if repo not in pkgs[name].keys(): | ||
pkgs[name][repo] = {} | ||
|
||
pkgs[name][repo]["ver"] = ver.strip("()") | ||
pkgs[name][repo]["desc"] = desc.strip() | ||
|
||
for (p, q) in pkgs.items(): | ||
desc = None | ||
ver = None | ||
abstract = [] | ||
for repo in repos: | ||
if repo in q.keys(): #11 | ||
abstract.append("%s (%s) %s https://packages.debian.org/%s/%s" % (repo, names[repo], q[repo]["ver"], names[repo], p)) | ||
if not desc: #we only need to show one of the descriptions, since they're all very similar. We'll prefer them in the order listed in the repos array | ||
desc = q[repo]["desc"] | ||
if not ver: #same for the screenshot | ||
ver = q[repo]["ver"] | ||
|
||
out = p + "\t" #0 | ||
out += "A\t" #1 | ||
out += "\t" #2 | ||
out += "\t" #3 | ||
out += "\t" #4 | ||
out += "\t" #5 | ||
out += "\t" #6 | ||
out += "\t" #7 | ||
out += "\t" #8 | ||
out += "\t" #9 | ||
out += "[[Image:https://screenshots.debian.net/thumbnail-with-version/%s/%s]]\t" % (p, ver) #10 | ||
out += desc + "<br>" + "<br>".join(abstract) #11 | ||
out += "\t" #12 | ||
print(out) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
python3 parse.py > output.txt |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elebow This isn't the correct output file format. I'd point you to the fathead docs but you wrote them 😏
I saw there were a few urls in the abstract text. I'd just pull one out (latest release?) and use that as the more at link.