Browse Source

Fix my stupidness

master
John ShaggyTwoDope Jenkins 5 years ago
parent
commit
bded67f5c5
29 changed files with 956 additions and 0 deletions
  1. 1
    0
      alienfeed-git/AlienFeed/HEAD
  2. 8
    0
      alienfeed-git/AlienFeed/config
  3. 1
    0
      alienfeed-git/AlienFeed/description
  4. 15
    0
      alienfeed-git/AlienFeed/hooks/applypatch-msg.sample
  5. 24
    0
      alienfeed-git/AlienFeed/hooks/commit-msg.sample
  6. 8
    0
      alienfeed-git/AlienFeed/hooks/post-update.sample
  7. 14
    0
      alienfeed-git/AlienFeed/hooks/pre-applypatch.sample
  8. 49
    0
      alienfeed-git/AlienFeed/hooks/pre-commit.sample
  9. 54
    0
      alienfeed-git/AlienFeed/hooks/pre-push.sample
  10. 169
    0
      alienfeed-git/AlienFeed/hooks/pre-rebase.sample
  11. 36
    0
      alienfeed-git/AlienFeed/hooks/prepare-commit-msg.sample
  12. 128
    0
      alienfeed-git/AlienFeed/hooks/update.sample
  13. 6
    0
      alienfeed-git/AlienFeed/info/exclude
  14. BIN
      alienfeed-git/AlienFeed/objects/pack/pack-d5ad7f522e9e5cb2f1d50ca355265c0167afa34d.idx
  15. BIN
      alienfeed-git/AlienFeed/objects/pack/pack-d5ad7f522e9e5cb2f1d50ca355265c0167afa34d.pack
  16. 20
    0
      alienfeed-git/AlienFeed/packed-refs
  17. 35
    0
      alienfeed-git/PKGBUILD
  18. BIN
      alienfeed-git/alienfeed-git-230d5a6-1-any.pkg.tar.xz
  19. BIN
      alienfeed-git/alienfeed-git-230d5a6-1.src.tar.gz
  20. BIN
      alienfeed-git/pkg/alienfeed-git/.MTREE
  21. 24
    0
      alienfeed-git/pkg/alienfeed-git/.PKGINFO
  22. 327
    0
      alienfeed-git/pkg/alienfeed-git/usr/bin/alien.py
  23. 10
    0
      alienfeed-git/pkg/alienfeed-git/usr/bin/alienfeed
  24. 11
    0
      alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/PKG-INFO
  25. 10
    0
      alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/SOURCES.txt
  26. 1
    0
      alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/dependency_links.txt
  27. 3
    0
      alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/entry_points.txt
  28. 1
    0
      alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/requires.txt
  29. 1
    0
      alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/top_level.txt

+ 1
- 0
alienfeed-git/AlienFeed/HEAD View File

@@ -0,0 +1 @@
ref: refs/heads/master

+ 8
- 0
alienfeed-git/AlienFeed/config View File

@@ -0,0 +1,8 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
url = git://github.com/jawerty/AlienFeed
fetch = +refs/*:refs/*
mirror = true

+ 1
- 0
alienfeed-git/AlienFeed/description View File

@@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.

+ 15
- 0
alienfeed-git/AlienFeed/hooks/applypatch-msg.sample View File

@@ -0,0 +1,15 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".

. git-sh-setup
test -x "$GIT_DIR/hooks/commit-msg" &&
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
:

+ 24
- 0
alienfeed-git/AlienFeed/hooks/commit-msg.sample View File

@@ -0,0 +1,24 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".

# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"

# This example catches duplicate Signed-off-by lines.

test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}

+ 8
- 0
alienfeed-git/AlienFeed/hooks/post-update.sample View File

@@ -0,0 +1,8 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".

exec git update-server-info

+ 14
- 0
alienfeed-git/AlienFeed/hooks/pre-applypatch.sample View File

@@ -0,0 +1,14 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".

. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
:

+ 49
- 0
alienfeed-git/AlienFeed/hooks/pre-commit.sample View File

@@ -0,0 +1,49 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)

# Redirect output to stderr.
exec 1>&2

# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.

This can cause problems if you want to work with people on other platforms.

To be portable it is advisable to rename the file.

If you know what you are doing you can disable this check using:

git config hooks.allownonascii true
EOF
exit 1
fi

# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --

+ 54
- 0
alienfeed-git/AlienFeed/hooks/pre-push.sample View File

@@ -0,0 +1,54 @@
#!/bin/sh

# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).

remote="$1"
url="$2"

z40=0000000000000000000000000000000000000000

IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi

# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done

exit 0

+ 169
- 0
alienfeed-git/AlienFeed/hooks/pre-rebase.sample View File

@@ -0,0 +1,169 @@
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.

publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi

case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac

# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?

# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}

# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi

# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up-to-date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi

exit 0

################################################################

This sample hook safeguards topic branches that have been
published from being rewound.

The workflow assumed here is:

* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).

* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.

* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.

The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.

With this workflow, you would want to know:

(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.

(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".

Let's look at this example:

o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"


A, B and C are topic branches.

* A has one fix since it was merged up to "next".

* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.

* C has not merged to "next" at all.

We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.

To compute (1):

git rev-list ^master ^topic next
git rev-list ^master next

if these match, topic has not merged in next at all.

To compute (2):

git rev-list master..topic

if this is empty, it is fully merged to "master".

+ 36
- 0
alienfeed-git/AlienFeed/hooks/prepare-commit-msg.sample View File

@@ -0,0 +1,36 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".

# This hook includes three examples. The first comments out the
# "Conflicts:" part of a merge commit.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.

case "$2,$3" in
merge,)
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;

# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$1" ;;

*) ;;
esac

# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"

+ 128
- 0
alienfeed-git/AlienFeed/hooks/update.sample View File

@@ -0,0 +1,128 @@
#!/bin/sh
#
# An example hook script to blocks unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#

# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"

# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi

if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi

# --- Config
allowunannotated=$(git config --bool hooks.allowunannotated)
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
denycreatebranch=$(git config --bool hooks.denycreatebranch)
allowdeletetag=$(git config --bool hooks.allowdeletetag)
allowmodifytag=$(git config --bool hooks.allowmodifytag)

# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac

# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero="0000000000000000000000000000000000000000"
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi

case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac

# --- Finished
exit 0

+ 6
- 0
alienfeed-git/AlienFeed/info/exclude View File

@@ -0,0 +1,6 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

BIN
alienfeed-git/AlienFeed/objects/pack/pack-d5ad7f522e9e5cb2f1d50ca355265c0167afa34d.idx View File


BIN
alienfeed-git/AlienFeed/objects/pack/pack-d5ad7f522e9e5cb2f1d50ca355265c0167afa34d.pack View File


+ 20
- 0
alienfeed-git/AlienFeed/packed-refs View File

@@ -0,0 +1,20 @@
# pack-refs with: peeled fully-peeled
230d5a67e801b3486463bf526cbaa1849302705d refs/heads/master
85ee2697964c86912b60c02567fcebaad5cda791 refs/heads/temp
7267f9ed6e34199e44d9384712463f5e0b454ade refs/pull/10/head
3ada0fedc99bccb9cef7387ff53f31b49da2b605 refs/pull/12/head
58330dae26e6e9c091fa65c611ec76dbf2bf6097 refs/pull/14/head
aec442dc2e5fae1e0490cc27cd275c30c86b6a68 refs/pull/15/head
93460d7c1bbf2aa062d6202c2d205c5912bd8c28 refs/pull/18/head
5a5b9d97451ffb1346a6cd59ef8c4b34d04a0ebf refs/pull/2/head
37a07188801b785514d613eb741d02d4fa46966b refs/pull/20/head
d9c770af94edc8e04525e975e45e0391acb03c59 refs/pull/22/head
26ae7ec6d2ea90ff3c74f41ee2f30eb975a2caa4 refs/pull/23/head
95afdf98ed08af8afc660d37dfdd9419ce24f782 refs/pull/23/merge
5c439c3ece6cfcf51ad3c79a1f0ec81e8b4f9d2d refs/pull/24/head
3c2b4045e1bbc8bbda3b64ff809e051e3f1244f1 refs/pull/24/merge
9b6fd838cf3b65bbb5ef79e7e824f0edee7646f1 refs/pull/25/head
b0495500b69d3dcd8c72b6feea58cc2f934296fe refs/pull/4/head
5cf0ccfbcad324a76729fc12711cafc47b79e62a refs/pull/6/head
d1d412e12f220c5d83a7bd9b6b082f9394f40331 refs/pull/8/head
d5e2980d1f5e77246df65b9f6bf0ee80fc5a2598 refs/pull/9/head

+ 35
- 0
alienfeed-git/PKGBUILD View File

@@ -0,0 +1,35 @@
# Maintainer: John Jekins twodopeshaggy@gmail.com

_pkgname=AlienFeed
pkgname=alienfeed-git
pkgver=230d5a6
pkgrel=1
pkgdesc="Reddit command-line client. Follow the latest submissions from your terminal."
url="http://github.com/jawerty/AlienFeed"
arch=('any')
license=('MIT')
depends=('python2-praw-git')
makedepends=('git' 'python2')
source=(git://github.com/jawerty/AlienFeed)
md5sums=('SKIP')


pkgver() {
cd $_pkgname
git describe --always | sed -e 's|-|.|g' -e 's|v||'
}

build(){

cd $_pkgname

sed -i "s|env python|env python2|" $srcdir/$_pkgname/alienfeed/alien.py

}

package() {
cd $_pkgname

python2 setup.py install --root="$pkgdir" --optimize=1

}

BIN
alienfeed-git/alienfeed-git-230d5a6-1-any.pkg.tar.xz View File


BIN
alienfeed-git/alienfeed-git-230d5a6-1.src.tar.gz View File


BIN
alienfeed-git/pkg/alienfeed-git/.MTREE View File


+ 24
- 0
alienfeed-git/pkg/alienfeed-git/.PKGINFO View File

@@ -0,0 +1,24 @@
# Generated by makepkg 4.2.0
# using fakeroot version 1.20.2
# Thu Jan 15 06:36:49 UTC 2015
pkgname = alienfeed-git
pkgver = 230d5a6-1
pkgdesc = Reddit command-line client. Follow the latest submissions from your terminal.
url = http://github.com/jawerty/AlienFeed
builddate = 1421303809
packager = Unknown Packager
size = 41984
arch = any
license = MIT
depend = python2-praw-git
makedepend = git
makedepend = python2
makepkgopt = strip
makepkgopt = docs
makepkgopt = !libtool
makepkgopt = !staticlibs
makepkgopt = emptydirs
makepkgopt = zipman
makepkgopt = purge
makepkgopt = !upx
makepkgopt = !debug

+ 327
- 0
alienfeed-git/pkg/alienfeed-git/usr/bin/alien.py View File

@@ -0,0 +1,327 @@
#!/bin/python2

from argparse import ArgumentParser, ArgumentTypeError
import math
import os
import random
from subprocess import call
import sys
from textwrap import TextWrapper
import webbrowser
import praw

# Praw (Reddit API Wrapper) initialization
USER_AGENT = ('AlienFeed v0.3.1 by u/jw989 seen on '
'Github http://github.com/jawerty/AlienFeed')

r = praw.Reddit(user_agent=USER_AGENT)


# Terminal color object. Used for colorful output
class TerminalColor(object):
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
SUBTEXT = '\033[90m'
INFO = '\033[96m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'

color = TerminalColor()

class LinkType(object):
NSFW = '[NSFW]'
POST = '[POST]'
PIC = '[PIC]'
ALBUM = '[ALBUM]'
VIDEO = '[VIDEO]'

def get_link_types(link):
types = []
image_types = ('jpg', 'jpeg', 'gif', 'png')
image_hosts = ('imgur', 'imageshack', 'photobucket', 'beeimg')

if link.url == link.permalink:
# link is a post
types.append(color.INFO + LinkType.POST + color.ENDC)
elif link.url.split('.')[-1].lower() in image_types:
# is it an image?
types.append(color.OKGREEN + LinkType.PIC + color.ENDC)
elif link.domain.split('.')[-2].lower() in image_hosts:
# supposedly for an album, can also be a single image
types.append(color.OKGREEN + LinkType.ALBUM + color.ENDC)
elif link.media:
# it's a video
types.append(color.OKGREEN + LinkType.VIDEO + color.ENDC)

if link.over_18:
# it's nsfw
types.append(color.FAIL + LinkType.NSFW + color.ENDC)

return ' '.join(types)

class _parser(ArgumentParser):
def error(self, message):
sys.stderr.write(color.FAIL +
'\nAlienFeed error: %s\n' % (message + color.ENDC))
self.print_help()
sys.exit(2)


# Gets a List of submissions in a desired form
# the submission_list parameter is a list of submissions (returned by Praw) to be processed
# verbose indicates whether it will post details about the list of submissions or just return it
def submission_getter(submission_list, verbose = False):
submissions = []
scores = []
subreddits = set()

for x, submission in enumerate(submission_list):
submissions.append(submission)
if verbose:
scores.append(submission.score)
subreddits.add(str(submission.subreddit))

if not verbose:
return submissions

count_width = int(math.log(len(submissions), 10)) + 1
score_width = len(str(max(scores)))

fmt = {'arrow': ' -> '}
indent = ' ' * (count_width + len(fmt['arrow']) + score_width + 1)

try:
_, terminal_width = os.popen('stty size', 'r').read().split()
terminal_width = int(terminal_width)
except:
terminal_width = 80

wrapper = TextWrapper(subsequent_indent = indent, width = terminal_width)

for i, submission in enumerate(submissions):
fmt['count'] = color.OKGREEN + str(i + 1).rjust(count_width)
fmt['score'] = color.WARNING + str(submission.score).rjust(score_width)
fmt['title'] = color.OKBLUE + submission.title
fmt['tags'] = get_link_types(submission)

if len(subreddits) > 1:
fmt['title'] += color.SUBTEXT + u' ({0})'.format(submission.subreddit)

wrap = wrapper.wrap(
u'{count}{arrow}{score} {title} {tags}'.format(**fmt))

for line in wrap:
print line

return submissions


# View a subreddit (i.e. display the links from it)
def subreddit_viewer(submission_list):
links = submission_getter(submission_list, verbose = True)

# Get a list of links for a subreddit
def get_submissions_from_subreddit(subreddit, limit):
links = []

try:
submissions = ( r.get_subreddit(subreddit).get_hot(limit = limit) if subreddit != 'front' else r.get_front_page(limit = limit) )
links = submission_getter(submissions)

except praw.errors.InvalidSubreddit, e:
print_warning("I'm sorry but the subreddit '{0}' does not exist; try again.".format(subreddit), "InvalidSubreddit:", e)

return links


# Print-related
def print_colorized(text):
print color.HEADER, text, color.ENDC

def print_warning(text, exc=None, exc_details=None):
if exc and exc_details:
print color.FAIL, exc, exc_details
print color.WARNING, text , color.ENDC

# Parse an argument value in the form of a range, like 1..5
def parse_range(string):
try:
splitted = string.split('..');
if (len(splitted) != 2):
raise ArgumentTypeError("'" + string + "' is not a valid range. Expected forms like '1..5'")

start = int(splitted[0])
end = int(splitted[1])

return splitted
except ValueError:
raise ArgumentTypeError("Range values are not valid integers. Expected forms like '1..5'")

# Main method
def main():
parser = _parser(description='''AlienFeed, by Jared Wright, is a
commandline application made for displaying and
interacting with recent Reddit links. I DO NOT HAVE
ANY AFILIATION WITH REDDIT, I AM JUST A HACKER''')

parser.add_argument("-l", "--limit", type=int, default=10,
help='Limits output (default output is 10 links)')
parser.add_argument("subreddit", default='front',
help="Returns top links from subreddit 'front' "
"returns the front page")
parser.add_argument("-o", "--open", type=int,
help='Opens one link that matches the number '
'inputted. Chosen by number')
parser.add_argument("-or", "--openrange", type=parse_range,
help="Opens a range of links of the form 'x..y', "
"where 'x' and 'y' are chosen numbers")
parser.add_argument("-s", "--self", action="store_true",
help="Displays the self text of a post")
parser.add_argument("-r", "--random", action='store_true',
help='Opens a random link (must be the only '
'optional argument)')
parser.add_argument("-U", "--update", action='store_true',
help='Automatically updates AlienFeed via pip')


# if only 1 argument, print the help
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)

# else, get the arguments
args = parser.parse_args()

subm_gen = None

# This holds the opened submissions, to further do operations on them (e.g. --self)
chosen_submissions = []

# Do acion depending on the passed arguments
# Open range of submissions case
if args.openrange:
if args.open or args.random:
print_warning("You cannot use [-or OPENRANGE] with [-o OPEN] or with [-r RANDOM]")
sys.exit(1)
else:
start = int(args.openrange[0])
end = int(args.openrange[1])

# ensure end is not above the limit
if end > args.limit:
print_warning("The upper range limit you typed was out of the feed's range"
" (try to pick a number between 1 and 10 or add --limit {0})")
sys.exit(1)
else:
end += 1 # add 1 to include upper end of range

# Get the submissions for the subreddit
submissions = get_submissions_from_subreddit(args.subreddit, args.limit)

print_colorized("Viewing a range of submissions\n")

for x in range(start, end):
# Chosen submission
chosen = submissions[x - 1]

# Save the chosen submission
chosen_submissions.append(chosen)

# Open the link
webbrowser.open(chosen.url)

# Invalid case
elif args.open and args.random:
print_warning("You cannot use [-o OPEN] with [-r RANDOM]")
sys.exit(1)

# Open a certain submisison case
elif args.open:
try:
# Get the submissions for the subreddit
submissions = get_submissions_from_subreddit(args.subreddit, args.limit)

print_colorized("Viewing a submission\n")

# Save chosen submission
chosen_submissions.append(submissions[args.open - 1]);

# Open desired link
webbrowser.open(submissions[args.open - 1].url)
except IndexError, e:
print_warning("The number you typed in was out of the feed's range"
" (try to pick a number between 1 and 10 or add"
" --limit {0})".format(e), "IndexError:", e)

# Random submission case
elif args.random:
if args.limit == 10:
if args.subreddit == 'front':
front = r.get_front_page(limit = 200)
submissions = submission_getter(front)
else:
top = r.get_subreddit(args.subreddit).get_top(limit = 200)
new = r.get_subreddit(args.subreddit).get_new(limit = 200)
hot = r.get_subreddit(args.subreddit).get_hot(limit = 200)
submissions = submission_getter(top)
submissions.extend(submission_getter(new))
submissions.extend(submission_getter(hot))

try:
# Get a random submission
chosen = random.choice(submissions)

# Save the chosen submission
chosen_submissions.append(chosen)

# Open the link
webbrowser.open( chosen.url )
print_colorized("Viewing a random submission\n")

except IndexError, e:
print_warning("There was an error with your input. "
"Hint: Perhaps the subreddit you chose was "
"too small to run through the program",
"IndexError:", e)
else:
print_warning("You cannot use [-l LIMIT] with [-r RANDOM] "
"(unless the limit is 10)")
sys.exit(1)

# Default case is listing Top 'limit' elements
else:
if args.subreddit == 'front':
submission_list = list(r.get_front_page(limit=args.limit))
print_colorized('Top {0} front page links:'.format(args.limit))
else:
submission_list = list(r.get_subreddit(args.subreddit).get_hot(limit=args.limit))
print_colorized('Top {0} /r/{1} links:'.format(args.limit, args.subreddit))

try:
# Save them to the chosen submissions
chosen_submissions.extend(submission_list)

# Display the Submissions
subreddit_viewer(submission_list)
except praw.errors.InvalidSubreddit, e:
print_warning("I'm sorry but the subreddit '{0}' does not exist; "
"try again.".format(args.subreddit), "InvalidSubreddit:", e)

# Self post case
if args.self:
print_colorized("Selft text of submission(s):")
for i, submission in enumerate(chosen_submissions):
print color.OKGREEN, "[" + str(i) + "] -> ", color.OKBLUE, submission.selftext, color.ENDC

# Update AlienFeed case
if args.update == True:
try:
print "Upgrading AlienFeed..."
call(['pip', 'install', 'alienfeed', '--upgrade', '--quiet'])
except OSError, e:
print_warning("You cannot use -U without having pip installed.")

if __name__ == '__main__':
main()

+ 10
- 0
alienfeed-git/pkg/alienfeed-git/usr/bin/alienfeed View File

@@ -0,0 +1,10 @@
#!/bin/python2
# EASY-INSTALL-ENTRY-SCRIPT: 'AlienFeed==0.3.1','console_scripts','alienfeed'
__requires__ = 'AlienFeed==0.3.1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
sys.exit(
load_entry_point('AlienFeed==0.3.1', 'console_scripts', 'alienfeed')()
)

+ 11
- 0
alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/PKG-INFO View File

@@ -0,0 +1,11 @@
Metadata-Version: 1.0
Name: AlienFeed
Version: 0.3.1
Summary: AlienFeed is a simple Reddit client for viewing and opening links from your console.
Home-page: http://github.com/jawerty/AlienFeed
Author: Jared Wright
Author-email: jawerty210@gmail.com
License: MIT
Description: UNKNOWN
Keywords: AlienFeed alien reddit feed rss tool cli
Platform: UNKNOWN

+ 10
- 0
alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/SOURCES.txt View File

@@ -0,0 +1,10 @@
MANIFEST.in
requirements.txt
setup.py
AlienFeed.egg-info/PKG-INFO
AlienFeed.egg-info/SOURCES.txt
AlienFeed.egg-info/dependency_links.txt
AlienFeed.egg-info/entry_points.txt
AlienFeed.egg-info/requires.txt
AlienFeed.egg-info/top_level.txt
alienfeed/alien.py

+ 1
- 0
alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/dependency_links.txt View File

@@ -0,0 +1 @@


+ 3
- 0
alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/entry_points.txt View File

@@ -0,0 +1,3 @@
[console_scripts]
alienfeed = alien:main


+ 1
- 0
alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/requires.txt View File

@@ -0,0 +1 @@
praw

+ 1
- 0
alienfeed-git/pkg/alienfeed-git/usr/lib/python2.7/site-packages/AlienFeed-0.3.1-py2.7.egg-info/top_level.txt View File

@@ -0,0 +1 @@


Loading…
Cancel
Save