apm_guess_file_type pathWhat it does:
Guesses and returns the file type key corresponding to a particular path (or an empty string if none is known).$path
should be relative to the package directory (e.g.,apm/admin-www/index.tcl
for
/packages/acs-core/apm/admin-www/index.tcl
. We use the following rules:Rules are applied in this order (stopping with the first match).
- Files with extension
.sql
are considered data-model files, or if any path contains the substringupgrade
, data-model upgrade files.- Files with extension
.info
are considered package specification files.- Files with a path component named
doc
are considered documentation files.- Files with extension
.pl
or.sh
or which have a path component namedbin
, are considered shell-executable files.- Files with a path component named
templates
are considered template files.- Files with extension
.html
or.adp
, in the top level of the package, are considered documentation files.- Files with a path component named
www
oradmin-www
are considered content-page files.- Files ending in
-procs.tcl
or-init.tcl
are considered Tcl procedure or Tcl initialization files, respectively.
Defined in: /web/philip/packages/acs-core/apm-procs.tcl
Source code:
set components [split $path "/"]
set extension [file extension $path]
set type ""
if { [string equal $extension ".sql"] } {
if { [lsearch -glob $components "*upgrade*"] >= 0 } {
set type "data_model_upgrade"
} else {
set type "data_model"
}
} elseif { [string equal $extension ".info"] } {
set type "package_spec"
} elseif { [lsearch $components "doc"] >= 0 } {
set type "documentation"
} elseif { [string equal $extension ".pl"] || [string equal $extension ".sh"] || [lsearch $components "bin"] >= 0 } {
set type "shell"
} elseif { [lsearch $components "templates"] >= 0 } {
set type "template"
} elseif { [llength $components] == 1 && ([string equal $extension ".html"] || [string equal $extension ".adp"]) } {
# HTML or ADP file in the top level of a package - assume it's documentation.
set type "documentation"
} elseif { [lsearch $components "www"] >= 0 || [lsearch $components "admin-www"] >= 0 } {
set type "content_page"
} else {
if { [string equal $extension ".tcl"] && [regexp -- {-(procs|init)\.tcl$} [file tail $path] "" kind] } {
set type "tcl_$kind"
}
}
return $type
philg@mit.edu