@sasjs/core 4.15.4 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ /**
2
+ @file
3
+ @brief Deletes a physical file, if it exists
4
+ @details Usage:
5
+
6
+ %mf_writefile(&sasjswork/myfile.txt,l1=some content)
7
+
8
+ %mf_deletefile(&sasjswork/myfile.txt)
9
+
10
+ %mf_deletefile(&sasjswork/myfile.txt)
11
+
12
+
13
+ @param filepath Full path to the target file
14
+
15
+ @returns The return code from the fdelete() invocation
16
+
17
+ <h4> Related Macros </h4>
18
+ @li mf_deletefile.test.sas
19
+ @li mf_writefile.sas
20
+
21
+ @version 9.2
22
+ @author Allan Bowe
23
+ **/
24
+
25
+ %macro mf_deletefile(file
26
+ )/*/STORE SOURCE*/;
27
+ %local rc fref;
28
+ %let rc= %sysfunc(filename(fref,&file));
29
+ %if %sysfunc(fdelete(&fref)) ne 0 %then %put %sysfunc(sysmsg());
30
+ %let rc= %sysfunc(filename(fref));
31
+ %mend mf_deletefile;
@@ -59,7 +59,7 @@
59
59
 
60
60
  %goto exit_success;
61
61
  %exit_err:
62
- %put %str(ERR)OR: &abortmsg;
62
+ %put &abortmsg;
63
63
  %mf_abort(iftrue=(&mabort ne SOFT),
64
64
  mac=mf_verifymacvars,
65
65
  msg=%str(&abortmsg)
@@ -94,6 +94,13 @@ data &out_ds(compress=no
94
94
  %end;
95
95
  if rc = 0 then do;
96
96
  did = dopen(fref);
97
+ if did=0 then do;
98
+ putlog "NOTE: This directory is empty, or does not exist - &path";
99
+ msg=sysmsg();
100
+ put msg;
101
+ put _all_;
102
+ stop;
103
+ end;
97
104
  /* attribute is OS-dependent - could be "Directory" or "Directory Name" */
98
105
  numopts=doptnum(did);
99
106
  do i=1 to numopts;
@@ -101,12 +108,6 @@ data &out_ds(compress=no
101
108
  if foption=:'Directory' then i=numopts;
102
109
  end;
103
110
  directory=dinfo(did,foption);
104
- if did=0 then do;
105
- putlog "NOTE: This directory is empty - " directory;
106
- msg=sysmsg();
107
- put _all_;
108
- stop;
109
- end;
110
111
  rc = filename(fref);
111
112
  end;
112
113
  else do;
@@ -242,4 +243,4 @@ run;
242
243
  proc sql;
243
244
  drop table &out_ds;
244
245
 
245
- %mend mp_dirlist;
246
+ %mend mp_dirlist;
@@ -49,20 +49,25 @@
49
49
 
50
50
 
51
51
  <h4> SAS Macros </h4>
52
- @li mf_loc.sas
53
- @li mm_tree.sas
54
52
  @li mf_getuniquefileref.sas
53
+ @li mf_getuniquename.sas
55
54
  @li mf_isblank.sas
55
+ @li mf_loc.sas
56
+ @li mm_tree.sas
56
57
  @li mp_abort.sas
57
58
 
58
- @param metaloc= the metadata folder to export
59
- @param secureref= fileref containing the username / password (should point to
60
- a file in a secure location). Leave blank to substitute $bash type vars.
61
- @param outref= fileref to which to write the command
62
- @param cmdoutloc= the directory to which the command will write the SPK
63
- (default=WORK)
64
- @param cmdoutname= the name of the spk / log files to create (will be
65
- identical just with .spk or .log extension)
59
+
60
+ @param [in] metaloc= the metadata folder to export
61
+ @param [in] secureref= fileref containing the username / password (should
62
+ point to a file in a secure location). Leave blank to substitute $bash vars.
63
+ @param [in] excludevars= (0) A space seperated list of macro variable names,
64
+ each of which contains a value that should be used to filter the output
65
+ objects.
66
+ @param [out] outref= fileref to which to write the command
67
+ @param [out] cmdoutloc= (%sysfunc(pathname(work))) The directory to which the
68
+ command will write the SPK
69
+ @param [out] cmdoutname= (mmxport) The name of the spk / log files to create
70
+ (will be identical just with .spk or .log extension)
66
71
 
67
72
  @version 9.4
68
73
  @author Allan Bowe
@@ -71,6 +76,7 @@
71
76
 
72
77
  %macro mm_spkexport(metaloc=
73
78
  ,secureref=
79
+ ,excludevars=0
74
80
  ,outref=
75
81
  ,cmdoutloc=%sysfunc(pathname(work))
76
82
  ,cmdoutname=mmxport
@@ -82,7 +88,7 @@
82
88
  %end;
83
89
 
84
90
  /* set creds */
85
- %local mmxuser mmxpath;
91
+ %local mmxuser mmxpath i var;
86
92
  %let mmxuser=$1;
87
93
  %let mmxpass=$2;
88
94
  %if %mf_isblank(&secureref)=0 %then %do;
@@ -90,35 +96,51 @@
90
96
  %end;
91
97
 
92
98
  /* setup metadata connection options */
93
- %local host port platform_object_path connx_string;
99
+ %local host port platform_object_path ds;
94
100
  %let host=%sysfunc(getoption(metaserver));
95
101
  %let port=%sysfunc(getoption(metaport));
96
102
  %let platform_object_path=%mf_loc(POF);
103
+ %let ds=%mf_getuniquename(prefix=spkexportable);
97
104
 
98
- %let connx_string=%str(-host &host -port &port -user &mmxuser %trim(
99
- )-password &mmxpass);
100
-
101
- %mm_tree(root=%str(&metaloc) ,types=EXPORTABLE ,outds=exportable)
105
+ %mm_tree(root=%str(&metaloc),types=EXPORTABLE ,outds=&ds)
102
106
 
103
107
  %if %mf_isblank(&outref)=1 %then %let outref=%mf_getuniquefileref();
104
108
 
105
109
  data _null_;
106
- set exportable end=last;
110
+ set &ds end=last;
107
111
  file &outref lrecl=32767;
108
112
  length str $32767;
109
113
  if _n_=1 then do;
114
+ put "# Script generated by &sysuserid on %sysfunc(datetime(),datetime19.)";
110
115
  put "cd ""&platform_object_path"" \";
111
- put "; ./ExportPackage &connx_string -disableX11 \";
112
- put " -package ""&cmdoutloc/&cmdoutname..spk"" \";
116
+ put "; ./ExportPackage -host &host -port &port -user &mmxuser \";
117
+ put " -disableX11 -password &mmxpass \";
118
+ put " -package ""&cmdoutloc/&cmdoutname..spk"" \";
113
119
  end;
120
+ /* exclude particular patterns from the exported SPK */
121
+ %if "&excludevars" ne "0" %then %do;
122
+ %do i=1 %to %sysfunc(countw(&excludevars));
123
+ %let var=%scan(&excludevars,&i);
124
+ if _n_=1 then do;
125
+ length excludestr&i $1000;
126
+ retain excludestr&i;
127
+ excludestr&i=symget("&var");
128
+ putlog excludestr&i=;
129
+ putlog path=;
130
+ end;
131
+ if index(path,cats(excludestr&i))=0 and index(name,cats(excludestr&i))=0;
132
+ %end;
133
+ /* ignore top level folder else all subcontent will be exported regardless */
134
+ if _n_>1;
135
+ %end;
114
136
  str=' -objects '!!cats('"',path,'/',name,"(",publictype,')" \');
115
137
  put str;
116
138
  if last then put " -log ""&cmdoutloc/&cmdoutname..log"" 2>&1 ";
117
139
  run;
118
140
 
119
141
  %mp_abort(iftrue= (&syscc ne 0)
120
- ,mac=&sysmacroname
142
+ ,mac=mm_spkexport
121
143
  ,msg=%str(syscc=&syscc)
122
144
  )
123
145
 
124
- %mend mm_spkexport;
146
+ %mend mm_spkexport;
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "@sasjs/cli": "3.6.0",
37
37
  "@sasjs/core": "4.4.7"
38
38
  },
39
- "version": "4.15.4"
39
+ "version": "4.17.0"
40
40
  }