-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
520 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/*** | ||
_v. 1.0.0_ | ||
Title | ||
===== | ||
__pkgzip__ - creates and downloads a Zip file from SSC and names it based on the package release date | ||
Syntax | ||
====== | ||
> __pkgzip__ _packagename_ | ||
Description | ||
=========== | ||
__pkgzip__ downloads a package from SSC. t will also analyze the last release | ||
date of the package and creates a Zip file with the release date, to imply the | ||
version of the package. packages hosted on SSC do not have a version specified | ||
within the package description and instead, the release date is used to show | ||
package versions. | ||
Example(s) | ||
================= | ||
download adoedit package from SSC, along with its version | ||
. pkgzip adoedit | ||
Author | ||
====== | ||
E. F. Haghish | ||
Department of Mathematics and Computer Science (IMADA) | ||
University of Southern Denmark | ||
- - - | ||
This help file was dynamically produced by | ||
[MarkDoc Literate Programming package](http://www.haghish.com/markdoc/) | ||
***/ | ||
|
||
|
||
|
||
|
||
*cap prog drop pkgzip | ||
prog pkgzip | ||
|
||
syntax [anything] | ||
ssclastupdate `anything', download remove | ||
|
||
end | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{smcl} | ||
{it:v. 1.0.0} | ||
|
||
|
||
{title:Title} | ||
|
||
{p 4 4 2} | ||
{bf:pkgzip} - creates and downloads a Zip file from SSC and names it based on the package release date | ||
|
||
|
||
{title:Syntax} | ||
|
||
{p 8 8 2} {bf:pkgzip} {it:packagename} | ||
|
||
|
||
|
||
{title:Description} | ||
|
||
{p 4 4 2} | ||
{bf:pkgzip} downloads a package from SSC. t will also analyze the last release | ||
date of the package and creates a Zip file with the release date, to imply the | ||
version of the package. packages hosted on SSC do not have a version specified | ||
within the package description and instead, the release date is used to show | ||
package versions. | ||
|
||
|
||
|
||
{title:Example(s)} | ||
|
||
download adoedit package from SSC, along with its version | ||
. pkgzip adoedit | ||
|
||
|
||
|
||
{title:Author} | ||
|
||
{p 4 4 2} | ||
E. F. Haghish {break} | ||
Department of Mathematics and Computer Science (IMADA) {break} | ||
University of Southern Denmark {break} | ||
|
||
{space 4}{hline} | ||
|
||
{p 4 4 2} | ||
This help file was dynamically produced by | ||
{browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package} | ||
|
||
|
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
|
||
*cap prog drop ssclastupdate | ||
prog ssclastupdate | ||
syntax [anything], [save(str) row(numlist) download remove] | ||
ssc describe "`anything'", saving(`anything', replace) | ||
qui cap translate "`anything'.smcl" "`anything'.log", replace translator(smcl2log) | ||
qui cap erase "`anything'.smcl" | ||
|
||
tempfile tmp | ||
tempname hitch | ||
qui file open `hitch' using "`anything'.log", read | ||
file read `hitch' line | ||
|
||
while r(eof) == 0 { | ||
|
||
local line: subinstr local line "`" "", all | ||
|
||
capture if substr(`"`macval(line)'"',1,5) == "TITLE" { | ||
file read `hitch' line | ||
local line1 = trim(`"`macval(line)'"') | ||
file read `hitch' line | ||
while substr(`"`macval(line)'"',1,2) == "> " & r(eof) == 0 { | ||
local line : subinstr local line "> " "" | ||
local line1 = "`line1" + trim("`line'") | ||
file read `hitch' line | ||
} | ||
if !missing("`save'") qui replace description = "`line1'" in `row' | ||
} | ||
|
||
cap if substr(trim(`"`macval(line)'"'),1,18) == "Distribution-Date:" { | ||
|
||
|
||
capture tokenize `"`line'"', parse(":") | ||
macro shift | ||
macro shift | ||
if !missing("`save'") qui replace update = `1' in `row' | ||
local ssclastupdate `1' | ||
|
||
|
||
|
||
if !missing("`save'") { | ||
preserve | ||
cap qui use `save', clear | ||
cap qui keep if package == "`anything'" | ||
if update == `ssclastupdate' local unupdated 1 | ||
|
||
restore | ||
|
||
if !missing("`unupdated'") { | ||
if !missing("`save'") qui replace drop = 1 in `row' | ||
local unupdated | ||
} | ||
|
||
else { | ||
|
||
local nv = versions in `row' | ||
local nv = `nv' + 1 | ||
if !missing("`save'") qui replace versions = `nv' in `row' | ||
|
||
//If the directory doesn't exist, create it | ||
confirmdir "`anything'/`anything'_`1'" | ||
if r(confirmdir) == "170" { | ||
if !missing("`download'") mkdir "`anything'/`anything'_`1'", public | ||
} | ||
local DIR "`anything'/`anything'_`1'" | ||
local NAME "`anything'_`1'" | ||
} | ||
} | ||
else { | ||
if !missing("`download'") mkdir "`anything'_`1'", public | ||
//otherwise just download the zip file | ||
local DIR "`anything'_`1'" | ||
local NAME "`anything'_`1'" | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
// Download the files | ||
if missing("`unupdated'") & !missing("`DIR'") & /// /// | ||
substr(`"`macval(line)'"',1,18) == "INSTALLATION FILES" { | ||
|
||
file read `hitch' line | ||
|
||
local adoNumber 0 //reset | ||
while substr(`"`macval(line)'"',1,9) != "ANCILLARY" & /// | ||
r(eof) == 0 & `"`macval(line)'"' != "" & /// /// | ||
substr(`"`macval(line)'"',1,9) != "---------" { | ||
|
||
tokenize "`line'", parse("/") | ||
while !missing("`1'") { | ||
local weirdo "`1'" | ||
macro shift | ||
} | ||
|
||
if !missing("`save'") { | ||
if substr("`weirdo'",-4,.) == ".ado" local adoNumber `++adoNumber' | ||
if substr("`weirdo'",-4,.) == ".dlg" qui replace dlg = 1 in `row' | ||
if substr("`weirdo'",-5,.) == ".mlib" qui replace mata = 1 in `row' | ||
if substr("`weirdo'",-5,.) == ".mata" qui replace mata = 1 in `row' | ||
if substr("`weirdo'",-3,.) == ".mo" qui replace mata = 1 in `row' | ||
if substr("`weirdo'",-2,.) == ".R" qui replace plugin = 1 in `row' | ||
if substr("`weirdo'",-6,.) == ".class" qui replace plugin = 1 in `row' | ||
if substr("`weirdo'",-7,.) == ".plugin" qui replace plugin = 1 in `row' | ||
if substr("`weirdo'",-6,.) == ".style" qui replace scheme = 1 in `row' | ||
} | ||
|
||
|
||
if missing("`fileslist'") local fileslist "`weirdo'" | ||
else local fileslist "`fileslist';`weirdo'" | ||
|
||
if !missing("`download'") { | ||
|
||
di as txt "`weirdo'" | ||
cap qui ssc copy "`weirdo'", replace | ||
|
||
cap qui capture copy "`weirdo'" "`DIR'/`weirdo'", replace | ||
cap qui capture erase "`weirdo'" | ||
} | ||
|
||
|
||
file read `hitch' line | ||
} | ||
|
||
if !missing("`save'") qui replace ado = `adoNumber' in `row' | ||
|
||
if !missing("`download'") { | ||
|
||
//Erase the directory | ||
qui zipfile "`DIR'", saving("`DIR'", replace) | ||
|
||
//Erase DIR | ||
dirlist "`DIR'" | ||
foreach lname in `r(fnames)' { | ||
if !missing("`remove'") cap erase "`DIR'/`lname'" | ||
} | ||
if !missing("`remove'") cap rmdir "`DIR'" | ||
} | ||
|
||
} | ||
|
||
if !missing("`save'") qui replace files = "`fileslist'" in `row' | ||
|
||
|
||
file read `hitch' line | ||
} | ||
qui file close `hitch' | ||
qui cap erase "`anything'.log" | ||
|
||
end | ||
|
||
|
Oops, something went wrong.