Skip to content

Commit

Permalink
Pastebinit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eloaders committed Nov 27, 2013
1 parent 96d34a6 commit 6c6eb0f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
37 changes: 34 additions & 3 deletions pastebinit
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,31 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

defaultPB = "http://pastebin.com" #Default pastebin
file_extension_map = {
r'^.+\.(patch|diff)$': 'diff',
r'^.+\.sh$': 'bash',
r'^.+\.pl$': 'perl',
r'^.+\.py$': 'python',
r'^.+\.rb$': 'ruby',
r'^.+\.tcl$': 'tcl',
r'^.+\.lua$': 'lua',
r'^.+\.vim$': 'vim',
r'^.+\.bat$': 'winbatch',
r'^.+\.xml$': 'xml',
r'^.+\.spec$': 'rpmspec',
r'^.+\.php(\d)?': 'php',
r'^.+\.sql$': 'sql',
r'^.+\.java$': 'java5',
r'^.+\.properties$': 'properties',
r'^.+\.[ch]$': 'c',
r'^.+\.(cc|cxx|cpp|hh|hxx|hpp)$': 'cpp',
r'^CMake.+': 'cmake',
r'^/+\.cmake$': 'cmake',
r'^(GNU)?[Mm]akefile$': 'make',
r'^.+\.mk$': 'make',
}

defaultPB = "http://susepaste.org" #Default pastebin
try:
import lsb_release
release = lsb_release.get_distro_information()['ID'].lower()
Expand Down Expand Up @@ -198,8 +222,8 @@ try:
#Example configuration file string
configexample = """\
<pastebinit>
<pastebin>http://paste.debian.net</pastebin>
<author>A pastebinit user</author>
<pastebin>http://susepaste.org</pastebin>
<author>SUSEuser</author>
<jabberid>nobody@nowhere.org</jabberid>
<format>text</format>
</pastebinit>
Expand Down Expand Up @@ -293,6 +317,13 @@ try:
sys.exit(_("Unable to read from: %s") % filename)
if not content:
sys.exit(_("You are trying to send an empty document, exiting."))
if format == "auto_guess":
for _r, _f in file_extension_map.iteritems():
if re.match(_r, filename):
format = _f
break
pass
pass

params = getParameters(website, pastebind, content, user, jabberid, version, format, parentpid, permatag, title, username, password) #Get the parameters array

Expand Down
5 changes: 3 additions & 2 deletions pastebinit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@
<term><option>-a <arg>author</arg></option> (default: $USER)</term>
</varlistentry>
<varlistentry>
<term><option>-b <arg>pastebin url</arg></option> (default is distro-specific with a fallback to pastebin.com)</term>
<term><option>-b <arg>pastebin url</arg></option> (default is susepaste)</term>
</varlistentry>
<varlistentry>
<term><option>-f <arg>format for syntax-highlighting</arg></option> (default: text)
(check pastebin's website for complete list, example: python)</term>
(check pastebin's website for complete list, example: python). The special argument
"auto_guess" (<option>-f auto_guess</option>) will trigger format guessing from file extension</term>
</varlistentry>
<varlistentry>
<term><option>-h</option> Help screen</term>
Expand Down
2 changes: 1 addition & 1 deletion src/i-nex/.settings
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ File[10]=".src/USB_Drives.module:13.0"
File[11]=".src/Asound_Drives.module:34.12"
File[12]=".src/Reportm.module:88.46"
File[13]=".src/FReport_Gen.form"
File[14]=".src/FReport_Gen.class:49.14"
File[14]=".src/FReport_Gen.class:49.13"
File[15]=".src/Start_App_Args.form"
File[16]=".src/Start_App_Args.class:2.0"
File[17]=".src/ChkPrm.module:21.19"
Expand Down

0 comments on commit 6c6eb0f

Please sign in to comment.