A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/sudar/gist-it/commit/a5c6ff92c11d3b10c8f39d92e19f4275ed1dd00e below:

Added the ability to specify line numbers to embed part of the file · sudar/gist-it@a5c6ff9 · GitHub

@@ -30,20 +30,41 @@ def parse( self, location ):

30 30 31 31

parse = {}

32 32 33 -

# user / respository / format / branch / path

33 +

# user / respository / format / branch / path : startline : endline

34 34

user = parse[ 'user' ] = splitpath[ 0 ]

35 35

repository = parse[ 'repository' ] = splitpath[ 1 ]

36 36

branch = parse[ 'branch' ] = splitpath[ 3 ]

37 -

path = parse[ 'path' ] = '/'.join( splitpath[ 4: ] )

37 + 38 +

if (':' in splitpath[-1]) :

39 +

# line numbers were specified

40 +

split_filename = splitpath[-1].split(':')

41 +

filename = split_filename[0]

42 + 43 +

if (len(split_filename) > 2):

44 +

#end line is also specified

45 +

parse['start_line'] = int(split_filename[1])

46 +

parse['end_line'] = int(split_filename[2])

47 +

else:

48 +

# end line was not specified

49 +

parse['start_line'] = int(split_filename[1])

50 +

parse['end_line'] = 0

51 + 52 +

else:

53 +

# line numbers were not specified

54 +

filename = splitpath[-1]

55 +

parse['start_line'] = 0

56 +

parse['end_line'] = 0

57 + 58 +

path = parse[ 'path' ] = '/'.join( splitpath[ 4: -1] ) + filename

38 59 39 60

# format = blob

40 61

splitpath[ 2 ] = 'blob'

41 -

blob_path = parse[ 'blob_path' ] = '/'.join( splitpath )

62 +

blob_path = parse[ 'blob_path' ] = '/'.join( splitpath[:-1] )

42 63

blob_url = parse[ 'blob_url' ] = urlparse.urljoin( 'https://github.com', blob_path )

43 64 44 65

# format = raw

45 66

splitpath[ 2 ] = 'raw'

46 -

raw_path = parse[ 'raw_path' ] = '/'.join( splitpath )

67 +

raw_path = parse[ 'raw_path' ] = '/'.join( splitpath[:-1] )

47 68

raw_url = parse[ 'raw_url' ] = urlparse.urljoin( 'https://github.com', raw_path )

48 69 49 70

user_repository = parse[ 'user_repository' ] = '/'.join([ user, repository ])

@@ -56,6 +77,6 @@ def __init__( self, **arguments ):

56 77

for key in [ 'user', 'repository', 'branch', 'path',

57 78

'blob_path', 'blob_url',

58 79

'raw_path', 'raw_url',

59 -

'user_repository', 'user_repository_branch_path', 'user_repository_url' ]:

80 +

'user_repository', 'user_repository_branch_path', 'user_repository_url', 'start_line', 'end_line' ]:

60 81

setattr( self, key, arguments[ key ] )

61 82

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4