Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf99375e

Browse files
committed
Merge pull request#6 from 4ndreaSt4gi/master
Add git.io service
2 parents0f17ca7 +4b1e37a commitf99375e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎services/github.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Shorty
2+
## Copyright 2012 Andrea Stagi
3+
## See LICENSE
4+
5+
## @url git.io
6+
classGithub(Service):
7+
8+
defshrink(self,bigurl):
9+
gitio_pattern='http(s)?://((gist|raw|develop(er)?)\.)?github\.com'
10+
gitio_re=re.compile(gitio_pattern)
11+
ifnotgitio_re.search(bigurl):
12+
raiseShortyError('URL must match %s'%gitio_pattern)
13+
resp=request('http://git.io',post_data="url=%s"%bigurl)
14+
forheaderinresp.info().headers:
15+
ifheader.startswith("Location:"):
16+
returnheader[10:].strip('\n\r')
17+
raiseShortyError('Failed to shrink url')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp