Last active
December 19, 2017 00:39
-
-
Save BlogBlocks/6a998d1fc27e2a85446590fb31e4629a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| """Creates a name based on a url: | |
| USAGE: | |
| URL_local = "News---Somali-hijackings-after-five-year-lull_icc-ccs.org_.html" | |
| Ntitle(URL_local) | |
| If used as a module: | |
| import Beautihelp | |
| Beautihelp.Ntitle(URL_local) | |
| """ | |
| def Ntitle(URL_local, exten = -5, length= -17, NewExt = ".txt"): | |
| #removes the period | |
| txt = URL_local.replace(".","_") | |
| #removes the extension 'exten' (Default: exten = -5 ) | |
| txt = txt[:exten] | |
| #removes all front characters keeping the last 'length' (Default: length= -17) | |
| txt = txt[length:] | |
| #Adds a ".txt" extension | |
| txt = txt+NewExt | |
| return txt | |
| #URL_local = "News---Maritime-piracy-report-sees-first-Somali-hijackings-after-five-year-lull_icc-ccs.org_.html" | |
| # Ntitle(URL_local) | |
| # prints: lull_icc-ccs_org_.txt | |
| # print Ntitle(URL_local, exten = -6, length=-11) | |
| # prints: icc-ccs_org.txt |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
made public