+++ /dev/null
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"
-" Take from the Debian package and the exemple on $VIM/vim_exemples
-" AUGROUP
-"
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-if has("autocmd")
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Set some sensible defaults for editing C-files
- "
- augroup cprog
- " Remove all cprog autocommands
- au!
-
- " When starting to edit a file:
- " For *.c and *.h files set formatting of comments and set C-indenting on.
- " For other files switch it off.
- " Don't change the order, it's important that the line with * comes first.
- autocmd BufRead * set formatoptions=tcql nocindent comments&
- autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
- augroup END
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "" Gzip and Bzip2 files support
- " Also, support editing of gzip-compressed files. DO NOT REMOVE THIS!
- " This is also used when loading the compressed helpfiles.
- "
- augroup gzip
- " Remove all gzip autocommands
- au!
-
- " Enable editing of gzipped files
- " read: set binary mode before reading the file
- " uncompress text in buffer after reading
- " write: compress file after writing
- " append: uncompress file, append, compress file
- autocmd BufReadPre,FileReadPre *.gz set bin
- autocmd BufReadPre,FileReadPre *.gz let ch_save = &ch|set ch=2
- autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip
- autocmd BufReadPost,FileReadPost *.gz set nobin
- autocmd BufReadPost,FileReadPost *.gz let &ch = ch_save|unlet ch_save
-" NB 19.07.14 autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . %:r
-
- autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r
- autocmd BufWritePost,FileWritePost *.gz !gzip -9 <afile>:r
-
- autocmd FileAppendPre *.gz !gunzip <afile>
- autocmd FileAppendPre *.gz !mv <afile>:r <afile>
- autocmd FileAppendPost *.gz !mv <afile> <afile>:r
- autocmd FileAppendPost *.gz !gzip <afile>:r
- augroup END
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " BZIP2
- "
- augroup bzip2
- " Remove all bzip2 autocommands
- au!
-
- " Enable editing of bzipped files
- " read: set binary mode before reading the file
- " uncompress text in buffer after reading
- " write: compress file after writing
- " append: uncompress file, append, compress file
- autocmd BufReadPre,FileReadPre *.bz2 set bin
- autocmd BufReadPre,FileReadPre *.bz2 let ch_save = &ch|set ch=2
- autocmd BufReadPost,FileReadPost *.bz2 set cmdheight=2|'[,']!bunzip2
- autocmd BufReadPost,FileReadPost *.bz2 set cmdheight=1 nobin|execute ":doautocmd BufReadPost " . %:r
- autocmd BufReadPost,FileReadPost *.bz2 let &ch = ch_save|unlet ch_save
-
- autocmd BufWritePost,FileWritePost *.bz2 !mv <afile> <afile>:r
- autocmd BufWritePost,FileWritePost *.bz2 !bzip2 <afile>:r
-
- autocmd FileAppendPre *.bz2 !bunzip2 <afile>
- autocmd FileAppendPre *.bz2 !mv <afile>:r <afile>
- autocmd FileAppendPost *.bz2 !mv <afile> <afile>:r
- autocmd FileAppendPost *.bz2 !bzip2 -9 --repetitive-best <afile>:r
- augroup END
-
-endif " has ("autocmd")
-
--- /dev/null
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+"
+" Take from the Debian package and the exemple on $VIM/vim_exemples
+" AUGROUP
+"
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if has("autocmd")
+
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+ " Set some sensible defaults for editing C-files
+ "
+ augroup cprog
+ " Remove all cprog autocommands
+ au!
+
+ " When starting to edit a file:
+ " For *.c and *.h files set formatting of comments and set C-indenting on.
+ " For other files switch it off.
+ " Don't change the order, it's important that the line with * comes first.
+ autocmd BufRead * set formatoptions=tcql nocindent comments&
+ autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
+ augroup END
+
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+ "" Gzip and Bzip2 files support
+ " Also, support editing of gzip-compressed files. DO NOT REMOVE THIS!
+ " This is also used when loading the compressed helpfiles.
+ "
+ augroup gzip
+ " Remove all gzip autocommands
+ au!
+
+ " Enable editing of gzipped files
+ " read: set binary mode before reading the file
+ " uncompress text in buffer after reading
+ " write: compress file after writing
+ " append: uncompress file, append, compress file
+ autocmd BufReadPre,FileReadPre *.gz set bin
+ autocmd BufReadPre,FileReadPre *.gz let ch_save = &ch|set ch=2
+ autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip
+ autocmd BufReadPost,FileReadPost *.gz set nobin
+ autocmd BufReadPost,FileReadPost *.gz let &ch = ch_save|unlet ch_save
+" NB 19.07.14 autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . %:r
+
+ autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r
+ autocmd BufWritePost,FileWritePost *.gz !gzip -9 <afile>:r
+
+ autocmd FileAppendPre *.gz !gunzip <afile>
+ autocmd FileAppendPre *.gz !mv <afile>:r <afile>
+ autocmd FileAppendPost *.gz !mv <afile> <afile>:r
+ autocmd FileAppendPost *.gz !gzip <afile>:r
+ augroup END
+
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+ " BZIP2
+ "
+ augroup bzip2
+ " Remove all bzip2 autocommands
+ au!
+
+ " Enable editing of bzipped files
+ " read: set binary mode before reading the file
+ " uncompress text in buffer after reading
+ " write: compress file after writing
+ " append: uncompress file, append, compress file
+ autocmd BufReadPre,FileReadPre *.bz2 set bin
+ autocmd BufReadPre,FileReadPre *.bz2 let ch_save = &ch|set ch=2
+ autocmd BufReadPost,FileReadPost *.bz2 set cmdheight=2|'[,']!bunzip2
+ autocmd BufReadPost,FileReadPost *.bz2 set cmdheight=1 nobin|execute ":doautocmd BufReadPost " . %:r
+ autocmd BufReadPost,FileReadPost *.bz2 let &ch = ch_save|unlet ch_save
+
+ autocmd BufWritePost,FileWritePost *.bz2 !mv <afile> <afile>:r
+ autocmd BufWritePost,FileWritePost *.bz2 !bzip2 <afile>:r
+
+ autocmd FileAppendPre *.bz2 !bunzip2 <afile>
+ autocmd FileAppendPre *.bz2 !mv <afile>:r <afile>
+ autocmd FileAppendPost *.bz2 !mv <afile> <afile>:r
+ autocmd FileAppendPost *.bz2 !bzip2 -9 --repetitive-best <afile>:r
+ augroup END
+
+endif " has ("autocmd")
+
" Command to check files per file types
"
" rows.fields=id,cmd_check
-">SHELL_REPLACE echo "let mimeCheck = {"; nb_api '/pub/meta/ls/key,val.csv?cat=file.check' | tail -n +2 | sort -k 1 | sed -E -e "s/'/''/g" -e "s/^(.*?)\t(.*)$/ \\\,'\1' : '\2'/" -e "0,/,/s/,//"; echo "\}"
+">SHELL_REPLACE nb_api '/nb/meta/ls/key,val.vim_hash?cat=file.check&preff=%09&name=mimeCheck'
let mimeCheck = {
- \'bash' : 'bash -c'
- \,'erb' : 'sh -c "cat | erb -x - | ruby -c" <'
- \,'haproxy' : 'haproxy -c -f'
- \,'html' : 'xmllint --noout --html'
- \,'json' : 'ruby -rjson -e ''puts JSON.parse(File.read(ARGV[0]))'''
- \,'perl' : 'perl -c -w'
- \,'php' : 'php --define error_reporting=22519 --define display_errors=1 --define log_errors=1 --define html_errors=0'
- \,'puppet' : 'perl -e ''system qq/puppet parser validate $ARGV[0] && puppet-lint --no-selector_inside_resource-check --no-autoloader_layout-check --no-hard_tabs-check --no-80chars-check $ARGV[0]/'''
- \,'python' : 'python -m py_compile'
- \,'ruby' : 'ruby -c'
- \,'sh' : 'sh -c'
- \,'xml' : 'xmllint --noout'
- \,'yaml' : 'ruby -ryaml -e ''''puts YAML.dump(YAML.load_file(ARGV[0]))'''
+ \ 'bash' : 'bash -c'
+ \,'erb' : 'sh -c "cat | erb -x - | ruby -c" <'
+ \,'haproxy': 'haproxy -c -f'
+ \,'html' : 'xmllint --noout --html'
+ \,'json' : 'ruby -rjson -e ''puts JSON.parse(File.read(ARGV[0]))'''
+ \,'lua' : 'lua'
+ \,'perl' : 'perl -c -w'
+ \,'php' : 'php --define error_reporting=22519 --define display_errors=1 --define log_errors=1 --define html_errors=0'
+ \,'puppet' : 'perl -e ''system qq/puppet parser validate $ARGV[0] && puppet-lint --no-selector_inside_resource-check --no-autoloader_layout-check --no-hard_tabs-check --no-80chars-check $ARGV[0]/'''
+ \,'python' : 'python -m py_compile'
+ \,'ruby' : 'ruby -c'
+ \,'sh' : 'sh -c'
+ \,'xml' : 'xmllint --noout'
+ \,'yaml' : 'ruby -ryaml -e ''puts YAML.dump(YAML.load_file(ARGV[0]))'''
\}
"<SHELL_REPLACE
-- for tag in self:values(tags) do
-- content = content:gsub(" +(</th>)","%1")
-- end
+ -- Fix markdown module
content = content:gsub(" +(</th>)","%1")
content = content:gsub("(<th>) +","%1")
content = content:gsub(" +(</td>)","%1")
if (is_scalar($v) and self::is_binary($v)) $row[$k] = base64_encode($v);
}
+ if (!empty($o['quote'])) $row = self::quote($row,$o);
+
# buffering
if (!empty($o['align'])) {
if (!isset($o['sep'])) $o['sep'] = $o['align'];
$tmp_row = $row;
foreach ($tmp_row as $k => $v) {
if (!isset($o['length'][$k])) $o['length'][$k] = 0;
- if (!empty($o['quote'])) $tmp_row[$k] = $v = self::quote($v,$o['quote'],isset($o['quote_escape']) ? $o['quote_escape'] : null);
+# NB 08.05.18 if (!empty($o['quote'])) $tmp_row[$k] = $v = self::quote($v,$o);
$l = mb_strlen($v,self::charset());
if ($l > $o['length'][$k]) $o['length'][$k] = $l;
}
$o['rows'][] = $tmp_row;
return true;
+ }
+
# user function
- } elseif (self::type_call('row',$o,$row)) {
+ if (self::type_call('row',$o,$row)) {
$ret = true;
# html/xml tag style
}
public static function quote($str,$quote='"',$quote_escape='\\') {
- if ($quote === null or $quote == true) $quote = '"';
+ if (is_array($str)) {
+ foreach ($str as $k=>$v) {
+ $str[$k] = self::quote($v,$quote,$quote_escape);
+ }
+ return $str;
+ }
+
+ if (is_array($quote)) {
+ if (isset($quote['quote_escape'])) $quote_escape = $quote['quote_escape'];
+ $quote = $quote['quote'];
+ }
+
+ if ($quote === null or $quote === true) $quote = '"';
if ($quote_escape === null) $quote_escape = '\\';
+
$str = str_replace($quote,$quote_escape.$quote,$str);
$str = $quote . $str . $quote;
return $str;
$values = [];
foreach (array_values($row) as $k=>$v) {
-# NB 14.12.17 if (self::is_binary($v)) {
-# NB 14.12.17 $values[] = $v;
-# NB 14.12.17 break;
-# NB 14.12.17 }
- if (!empty($o['quote'])) $v = $o['quote'] .
- str_replace($o['quote'],$o['quote_escape'].$o['quote'],$v)
- . $o['quote'];
+# NB 08.05.18 if (!empty($o['quote'])) $v = self::quote($v,$o);
$values[] = str_replace("\n",'\\n',str_replace("\r","",self::scalar($v)));
}
'preff' => self::p('preff',''),
'row' => function (&$o,&$r) {
if ($o['preff']) echo $o['preff'];
+
$keys = array_keys($r);
for ($i=2;$i<count($keys);$i++) {
$k = $keys[$i];
<?php
-return [ 'align' => self::p('sep',':'), 'eol' => "\n", 'quote' => "'",
-'row' => function (&$o,&$r) {
- static $count;
- echo '\\'.( empty($count) ? ' ' : ',' );
- $count++;
+return [
+ 'align' => self::p('sep',': '),
+ 'eol' => "\n",
+ 'quote' => "'",
+ 'quote_escape' => "'",
+ 'preff' => self::p('preff',''),
+ 'name' => self::p('name','CHANGEME'),
+ 'head' => function (&$o,&$r) {
+ echo 'let '.$o['name'].' = {';
+ },
+ 'end' => function (&$o,&$r) {
+ echo '\\}'.$o['eol'];
+ },
+ 'row' => function (&$o,&$r) {
+ static $count;
+ if ($o['preff']) echo $o['preff'];
+ echo '\\'.( empty($count) ? ' ' : ',' );
+ $count++;
- $keys = array_keys($r);
- for ($i=2;$i<count($keys);$i++) {
- $k = $keys[$i];
- unset($r[$k]);
- }
+ $keys = array_keys($r);
+ for ($i=2;$i<count($keys);$i++) {
+ $k = $keys[$i];
+ unset($r[$k]);
+ }
},
];
?>
echo 'PRAGMA encoding="UTF-8";'
echo 'PRAGMA foreign_keys=OFF;'
- #dbq2sqlite db=pub 'table-name=!~^(zipcode|geo)'
- nb_api '/pub/dump/sqlite?table-name=!~^(zipcode|geo)'
+ nb_api '/pub/dump/sqlite?table-name=!~^(zipcode|geo|meta)'
echo 'VACUUM;'
) | sqlite3 "nb.db"