1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
// End user function
// Show information on a package
function atomsShow(package)
// Load Atoms Internals lib if it's not already loaded
// =========================================================================
if ~ exists("atomsinternalslib") then
load("SCI/modules/atoms/macros/atoms_internals/lib");
end
rhs = argn(2);
// Check number of input arguments
// =========================================================================
if rhs <> 1 then
error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsShow",1));
end
// Check input parameters type
// =========================================================================
if type(package) <> 10 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"atomsShow",1));
end
if size(package(1,:),"*") > 2 then
error(msprintf(gettext("%s: Wrong size for input argument #%d: 1x1 or 1x2 string matrix expected.\n"),"atomsShow",1));
end
// Remove leading and trailing parameters
// =========================================================================
package = stripblanks(package);
// If the version is not mentioned, complete with an empty string
// =========================================================================
if size(package,"*") == 1 then
package = [ package "" ];
end
// Check if it's a valid package
// =========================================================================
if ~atomsIsInstalled(package) & ~atomsIsPackage(package) then
if isempty(package(2)) then
module_full_name = package(1);
else
module_full_name = package(1)+" - "+package(2);
end
atomsError("error",msprintf(gettext("%s: The package %s is not available.\n"),"atomsShow",module_full_name));
end
// If version is not mentioned, the Most Recent Version is used
// =========================================================================
if isempty(package(2)) then
package(1,2) = atomsGetMRVersion(package(1));
end
// Get the details of this package
// =========================================================================
details = atomsToolboxDetails(package);
fields_map = [];
fields_map = [ fields_map ; "Toolbox" gettext("Package") ];
fields_map = [ fields_map ; "Title" gettext("Title") ];
fields_map = [ fields_map ; "Summary" gettext("Summary") ];
fields_map = [ fields_map ; "Version" gettext("Version") ];
fields_map = [ fields_map ; "Depends" gettext("Depend") ];
fields_map = [ fields_map ; "Category" gettext("Category(ies)") ];
fields_map = [ fields_map ; "Author" gettext("Author(s)") ];
fields_map = [ fields_map ; "Maintainer" gettext("Maintainer(s)") ];
fields_map = [ fields_map ; "Entity" gettext("Entity") ];
fields_map = [ fields_map ; "WebSite" gettext("WebSite") ];
fields_map = [ fields_map ; "License" gettext("License") ];
fields_map = [ fields_map ; "ScilabVersion" gettext("Scilab Version") ];
fields_map = [ fields_map ; "Status" gettext("Status") ];
if atomsIsInstalled(package) then
fields_map = [ fields_map ; "InstallAutomaticaly" gettext("Automatically Installed")];
fields_map = [ fields_map ; "installPath" gettext("Install Directory")];
end
fields_map = [ fields_map ; "Description" gettext("Description") ];
// Show it
// =========================================================================
max_field_len = max( length(fields_map(:,2)) );
fields_map(:,2) = justify(fields_map(:,2),"r");
for i=1:size(fields_map(:,1),"*")
value = "";
//
// Status
//
if fields_map(i,1)=="Status" then
if atomsIsInstalled(package) then
value = "Installed";
else
value = "Not installed";
end
end
//
// Automatically Installed ?
//
if fields_map(i,1)=="InstallAutomaticaly" then
if atomsGetInstalledStatus(package) == "A" then
value = "yes";
else
value = "no";
end
end
//
// Scilab Version
//
if fields_map(i,1)=="ScilabVersion" then
if regexp( details(fields_map(i,1)) , "/^~/" , "o" )<>[] then
value = "any";
else
value = details(fields_map(i,1));
end
end
//
// Dependences
//
if fields_map(i,1)=="Depends" then
value = dep2str(details(fields_map(i,1)));
end
//
// Other
//
if isempty(value) then
value = details(fields_map(i,1));
end
for j=1:size(value,"*")
if j==1 then
mprintf("% "+string(max_field_len)+"s : %s\n",fields_map(i,2),value(j))
else
mprintf("% "+string(max_field_len)+"s %s\n","",value(j))
end
end
end
endfunction
// =============================================================================
// string = dep2str(string)
//
// Convert a technical dependence string (For ex. : ">= toolbox_1 1.3") to a
// display dependence string (For ex. : "toolbox_1 (>= 1.3)" )
//
// =============================================================================
function str = dep2str(dep)
str = [];
if isempty(dep) then
return;
end
for i=1:size(dep,"*")
this_dep = dep(i);
// direction part
this_dep = stripblanks(this_dep);
direction_length = regexp(this_dep,"/\s/","o");
direction = stripblanks(part(this_dep,1:direction_length-1));
// name part
this_dep = stripblanks(part(this_dep,direction_length+1:length(this_dep)));
name_length = regexp(this_dep,"/\s/","o");
name = part(this_dep,1:name_length-1);
// version part
version = stripblanks(part(this_dep,name_length:length(this_dep)));
this_str = name+" ";
if direction == "~" then
this_str = this_str + "(Any version)";
else
this_str = this_str + "("+direction+" "+version+")";
end
str = [ str ; this_str ];
end
endfunction
|